1

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?

joe_deniable
  • 2,562
  • 3
  • 28
  • 38

4 Answers4

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
  • 1
    Awesome! 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.xmllook 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