I could understand if the API level required by the call was higher than the minimum, but why should it be a problem if it's equal to the minimum?
Asked
Active
Viewed 4,641 times
1
-
1Let me guess you are using `Android Studio` and seeing this error? – tyczj May 24 '13 at 20:38
-
Yes, in Android Studio. – joe_deniable May 24 '13 at 20:40
-
http://tools.android.com/tips/lint-checks. check the link – Raghunandan May 24 '13 at 20:44
-
1It's an Android Studio bug – Benoit May 24 '13 at 20:46
-
OK, I am just going to suppress the warning, thank you. – joe_deniable May 24 '13 at 20:55
4 Answers
5
I got the same problem in Android Studio; it was not a problem in IntelliJ which I had been using prior to AS.
To "fix it" I simply used the TargetApi annotation:
@TargetApi(8)
I only added it to my main Activity and the warnings went away everywhere.

free3dom
- 18,729
- 7
- 52
- 51
-
1Awesome! If you conditionally load a class when `Build.VERSION.SDK_INT > n`, then putting `@TargetApi(n)` on that class will suppress the undesired red warnings. – Jerry101 Oct 21 '14 at 03:09
5
This was a bug in Android Studio 0.1. It is fixed for 0.1.1
See fix: https://android-review.googlesource.com/#/c/58798/1

Siva Velusamy
- 2,471
- 17
- 9
0
In AndroidManifest.xml
look at uses-sdk
and value of android:minSdkVersion
. Make sure specified sdk version has level equal or higher then 8.

Volodymyr Lykhonis
- 2,936
- 2
- 17
- 13
-
The minimum SDK level is set to 8, that's why I don't understand why it's complaining about an API level 8 call. – joe_deniable May 24 '13 at 20:46
-
When using the gradle build, set `minSdkVersion` and `targetSdkVersion` in `build.grade` instead of the `
` element in `AndroidManifest.xml`. *Still,* Android Studio 0.6.1 is warning that some layout resources "requires API level 11 (current min is 1)" even though it's set to 13. – Jerry101 Jun 18 '14 at 01:06
0
Android Studio has some lint problems because I have this same problem too. The project should still build though. if not just do a simple check for the build version
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.ECLAIR_MR1){
//code goes here
}
and that should suppress the lint check

tyczj
- 71,600
- 54
- 194
- 296