I am having trouble compiling and running the ActionBarCompat sample of Android 16. I have API level 16 as the build target selected, which seems to build fine, but when I try to debug these errors pop up. Of course I could change the min API level in the manifest, but what would be the point of that? I have made no changes to the sample, so how come it is not working properly?
Class requires API level 14 (current min is 3): android.view.ActionProvider SimpleMenuItem.java /ActionBarCompat/src/com/example/android/actionbarcompat line 129 Android Lint Problem
Class requires API level 14 (current min is 3): android.view.ActionProvider SimpleMenuItem.java /ActionBarCompat/src/com/example/android/actionbarcompat line 134 Android Lint Problem
Class requires API level 14 (current min is 3): android.view.MenuItem.OnActionExpandListener SimpleMenuItem.java /ActionBarCompat/src/com/example/android/actionbarcompat line 155 Android Lint Problem
I am thoroughly confused, any help would be appreciated.
UPDATE: I have added the @TargetApi(14) annotations, then added Lint suppres newApi to one of the methoeds and now it seems to be running fine. I am even more confused. Could anybody shed some light on what's going on?
Sadly, these samples are not kept up to date for each SDK iteration.
-First thing first, you have setted a min of sdkversion = 3
? That seems a little low to me. 7 (eclair) is I think the minimum version most projects should focus on.
Lower level versions have a ridiculous market share and it will keep decreasing.
-These are Lint warnings. Lint is kinda new to Android, this is why this sample does not take it into account. It tells you about potential problems in your code. This warning means you are calling a level 14 class in a code that can run on a level 3 terminal. You should try to remove them with an @TargetApi(14)
annotation. This annotation tells to Lint that you know what you are doing and this code will only run for sdk version=14 at minimum.
-Also, if you want to use the actionbar with any version of Android, what you really want to use is the open source ActionBar Sherlock library. One step at a time though :-)