Question

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?

Was it helpful?

Solution

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 :-)

OTHER TIPS

In your manifest, you define android:minSdkVersion="3", yet you are making calls to API level 14 classes/methods.

Lint will check these types of API calls and give you a warning.

Obviously in the ActionBarCompat the current API level is checked to ensure it is safe to make the call.

To remove the warning simply add @TargetApi(14) before the method where you make the call.

You need to change the Project build target to API level 14..in (project->properties->Android)

These are their requirments:

Due to the use of the native action bar and its related classes on Ice Cream Sandwich, the library requires that both it and your project are compiled with Android 4.0 or newer. The project also requires that you are compiling with JDK 1.6 in both your editor and any build systems that you may be using.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top