1

In my manifest.xml I have defined:

    <uses-sdk android:minSdkVersion:"8" android:targetSdkVersion:"8" />

and in android's documentation for View class it's been said:

    setBackground(Drawable) 
    // ADDED IN API LEVEL 16

This method has been added in api level 16. But when I use it in my code, eclipse doesn't issue any complaint and my app crashes on devices running api under 16.

Where am I wrong?

donfuxx
  • 11,277
  • 6
  • 44
  • 76
Joseph_Marzbani
  • 1,796
  • 4
  • 22
  • 36

3 Answers3

3

you probably target Version 8 but compile with 19.

Philip
  • 1,068
  • 3
  • 12
  • 21
  • What do you mean? I compile with 19? what does this mean ? – Joseph_Marzbani Mar 17 '14 at 22:24
  • when you created the project you had three options to set, `min sdk`, `target sdk` and `compile with` you usually set the min-sdk to something around your value, depending on your application. the target-sdk depends on your application too, but the sdk you compile with is new latest one. – Philip Mar 17 '14 at 22:27
  • Mine (sdk version) is 17 actually. What should I do now? – Joseph_Marzbani Mar 17 '14 at 22:50
2

You could configure your project's Android Lint preferences like this:

  1. go to project --> properties --> Android Lint Preferences
  2. Set NewApi to severity error
  3. Click Apply button

enter image description here


then it should underline the setBackground method red and mark it as an error. That works for me in my project.

donfuxx
  • 11,277
  • 6
  • 44
  • 76
0

You are compiling against a version higher than 16. Go to your project.properties file at the root of your project and change the line target=android-someNumber to target=android-8.

AxiomaticNexus
  • 6,190
  • 3
  • 41
  • 61