I'm trying to make use of Actionbar Sherlock 4, targeting sdk 15 and min sdk 8. After following the directions provided on the Usage website and the great videos posted here: http://www.youtube.com/watch?v=avcp6eD_X2k
I'm still encountering a problem. When I try to add android:theme="@style/Theme.Sherlock" to my manifest file , I get the error:
No resource found that matches the given name (at 'theme' with value '@style/Theme.Sherlock').
I have included the actionbar Sherlock library project into my project, and the import statements are there and not coming up with any errors and I've
extends SherlockActivity implements ActionBar.TabListener
just like in the Demo code and documentation Yet still, eclipse gives me this error. Any ideas out there?
The pitfall I encountered was this: The reference to the ActionBarSherlock project needs to be in the Android->Libraries section of the project properties, while I had been adding it to the Build Path->Libraries.
I encountered a strange anomaly that might help!
Have built android project that uses ABS, running it on Gingerbread works fine, in ICS it crashes, the crash under ICS occurs due to this, check your AndroidManifest.xml (have trimmed out bits for brevity...
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:theme="@style/Theme.Sherlock">
It was the android:theme part that caused the crash under ICS, it worked fine under Gingerbread and older versions!. Solution was to remove it completely! Then from your Activity, do this:
@Override
public void onCreate(Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH){
this.setTheme(com.actionbarsherlock.R.style.Theme_Sherlock);
}
super.onCreate(savedInstanceState);
... // MORE CODE ....
}
This fixed up the crash under ICS, the theme style is not liked by ICS, but it works fine for both versions less than 2.3 and 4.0 upwards.. weird error but that I discovered by fluke!
Remember to apply the theme before calling the base class's own onCreate!
My standard procedure for including a library project on Eclipse goes like this:
That should fix whatever ails you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With