Code2care : TechZone Apps & Tutorials

Actionbar Sherlock IllegalStateException Exception



ActionBar Sherlock Force close due to Actionbar Sherlock IllegalStateException Exception


If your app just force closed with the following exception,

02-19 13:19:55.663: D/AndroidRuntime(759): Shutting down VM
02-19 13:19:55.663: W/dalvikvm(759): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
02-19 13:19:55.674: E/AndroidRuntime(759): FATAL EXCEPTION: main
02-19 13:19:55.674: E/AndroidRuntime(759): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.code2care.tools.example/com.code2care.tools.example.MainActivity}: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
02-19 13:19:55.674: E/AndroidRuntime(759): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
02-19 13:19:55.674: E/AndroidRuntime(759): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-19 13:19:55.674: E/AndroidRuntime(759): 	at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-19 13:19:55.674: E/AndroidRuntime(759): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-19 13:19:55.674: E/AndroidRuntime(759): 	at android.os.Handler.dispatchMessage(Handler.java:99)
02-19 13:19:55.674: E/AndroidRuntime(759): 	at android.os.Looper.loop(Looper.java:123)
02-19 13:19:55.674: E/AndroidRuntime(759): 	at android.app.ActivityThread.main(ActivityThread.java:4627)
02-19 13:19:55.674: E/AndroidRuntime(759): 	at java.lang.reflect.Method.invokeNative(Native Method)
02-19 13:19:55.674: E/AndroidRuntime(759): 	at java.lang.reflect.Method.invoke(Method.java:521)
02-19 13:19:55.674: E/AndroidRuntime(759): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-19 13:19:55.674: E/AndroidRuntime(759): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-19 13:19:55.674: E/AndroidRuntime(759): 	at dalvik.system.NativeStart.main(Native Method)
02-19 13:19:55.674: E/AndroidRuntime(759): Caused by: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
02-19 13:19:55.674: E/AndroidRuntime(759): 	at com.actionbarsherlock.internal.ActionBarSherlockCompat.generateLayout(ActionBarSherlockCompat.java:976)
02-19 13:19:55.674: E/AndroidRuntime(759): 	at com.actionbarsherlock.internal.ActionBarSherlockCompat.installDecor(ActionBarSherlockCompat.java:902)
02-19 13:19:55.674: E/AndroidRuntime(759): 	at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:836)
02-19 13:19:55.674: E/AndroidRuntime(759): 	at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:229)
02-19 13:19:55.674: E/AndroidRuntime(759): 	at com.code2care.tools.bmicalculatorpro.MainActivity.onCreate(MainActivity.java:32)
02-19 13:19:55.674: E/AndroidRuntime(759): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-19 13:19:55.674: E/AndroidRuntime(759): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
02-19 13:19:55.674: E/AndroidRuntime(759): 	... 11 more


When you read the stack trace, you see the cause of the error is,

"You must use Theme.Sherlock, Theme.Sherlock.Light"

That is , we need to set a sherlock theme for the activity in the Manifest file.

By default the Application theme is set as AppTheme, just change it theme options available with ActionBar Sherlock Theme.Sherlock.Light.DarkActionBar

By Default the Theme is AppTheme


Change AppTheme to SherlockTheme


Crash Error Fixed









Top


Posts related to ActionBarSherlock.


1. Actionbar Sherlock IllegalStateException Exception

2. ActionBarSherlock Implementation to Support Older Android SDK


Code2care : Lines of Code for Change
Code2care is an initiative to publish and share varied knowledge in technical and non-technical areas gathered during day-to-day learnings and development activities.





Android app on Google Play    








Popular tags
android
x 175
eclipse
x 29
notepadplusplus
x 20
macosx
x 14
sharepoint
x 14
html
x 14
mac
x 13
androidstudio
x 11




1000+ C Programs     PHP Tutorial     JSON Tutorial     Swift Tutorial     India Pinocdes     About Us     Privacy Policy


Code2care © 2012-17