How to ignore @JavascriptInterface annotation with strings in API 17 -Android

@JavascriptInterface annotation works on api 17 and above. For my project, the annotation cannot be found, since my target api is set to 13:

my project build target

and in my manifest, min sdk is 11:

<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="18" /> 

Why do I need to go to the project build target (e.g. Project> Properties> Android in Eclipse) and change it to API 17+ as permission. Now I have to create against this SDK when all I really want to do is ignore the annotation for anything below API 17. Is there anyway I can do this? I do not like the idea of ​​creating against api 17, and then figuring out that I have code that will not work in previous versions. My goal is to ensure that my application can work with api from 13 to 18. If commonsWare is around, maybe it can offer something that is missing ...

+4
source share
1 answer

For my project, the annotation cannot be found, since my target api is set to 13:

Then fix this or set android:targetSdkVersion low enough that you don't need @JavascriptInterface .

Why do I need to go to the project build target (e.g. Project> Properties> Android in Eclipse) and change it to API 17+ as permission.

Since @JavascriptInterface does not exist until API level 17, the same as DisplayManager does not exist until API level 17.

Now I need to build against this SDK when all I really want to do is ignore the annotation for anything below API 17.

Since your build target does not affect any other classes, methods, annotations, etc., I do not see this problem.

I do not like the idea of ​​creating against api 17, and then figuring out that I have code that will not work on previous releases.

Lint has been reporting API level violations for more than a year. Just make sure your android:minSdkVersion installed correctly.

In the end, you already relied on this, since your android:minSdkVersion set to 11 , and now your build target is set to 13. This means that you are counting Lint to tell where you are using API level 12 and API Level 13 API so you can handle them correctly. All you do is raise your build goal to increase the number of things you rely on Lint for.

+1
source

All Articles