I was going through this sample package which Google has provided with it’s sdk. I tried changing the api level to 7 and observed that there were many unresolved errors in the project.
I’m listing a few here:
- ICE_CREAM_SANDWICH cannot be resolved or is not a field (ActionBarActivity.java)
- R cannot be resolved to a variable (This is probably due to the fact my xml also contains errors)
- SHOW_AS_ACTION_IF_ROOM cannot be resolved or is not a field (ActionBarHelperBase.java)
- The method setActionView(View) is undefined for the type MenuItem (ActionBarHelperHoneycomb.java)
- The method getActionBar() is undefined for the type Activity (ActionBarHelperICS.java)
- The import android.view.ActionProvider cannot be resolved (SimpleMenuItem.java)
- in res/values-v13/styles.xml – error: Error retrieving parent for item: No resource found that matches the given name ‘android:style/
TextAppearance.Holo.Widget.ActionBar.Title’. - error: Error: No resource found that matches the given name: attr ‘android:actionBarStyle’. (in res/values-v11/styles.xml)
Any idea how to get rid of these errors? Basically I’m targeting android devices 2.x and later. Does using actionbarsherlock is another alternative? I read here on some post that action bar compatibility package works on 2.x android devices as well.
You shouldn’t change the api version. The manifest declares min-sdk-version as 4, which means it will work on 2.x devices. Try loading it on the emulator, using api version 14 to compile.