Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lint and old API level warning

Tags:

android

I compile against Android 4.2 (API 17), in my Manifest I have:

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

In code I use:

String first = sdf.format(new   Date(context.getPackageManager().getPackageInfo(context.getPackageName(), 0).firstInstallTime)); 

Field firstInstallTime was introduced in API 9.

Lint does not warn me, i.e. that this field is not valid in API 8. What am I missing, how should one detect this?

If I compile against Android 2.2 (API 8), I find the error and a bunch of extra errors due to new features used (> API 8) and the project won't compile.

(I'm aware of handling such things in runtime with for example Build.VERSION.SDK_INT)

What's the best way of working?

Why is lint not working?

Thanks!

like image 699
powder366 Avatar asked Dec 16 '12 14:12

powder366


1 Answers

This answer may be late but You should check your lint preferences

Right click on project -> Properties -> Android Lint Preferences

then search for min in the searchbox and select "UsesMinSDKAttributes"

Finally select "Include all" button. Hopefully the check had just been surpressed (Something I've had to do just to fix a silly lint error)

Good luck.

like image 114
TheMcMurder Avatar answered Oct 29 '22 17:10

TheMcMurder