ActionBarSherlock icon indicating copy to clipboard operation
ActionBarSherlock copied to clipboard

java.lang.IllegalStateException: You must use Theme.Sherlock, ... even if I am allready using it

Open voydz opened this issue 11 years ago • 7 comments

On very few Devices (i.e. a GT-P6800) I get a:

java.lang.RuntimeException: Unable to start activity ComponentInfo{de.felitec.dow/de.felitec.dow.ui.LoginActivity}: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1815)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
at android.app.ActivityThread.access$500(ActivityThread.java:122)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4123)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
at com.actionbarsherlock.internal.ActionBarSherlockCompat.generateLayout(ActionBarSherlockCompat.java:976)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.installDecor(ActionBarSherlockCompat.java:902)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:836)
at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:229)
at de.felitec.dow.ui.LoginActivity.onCreate(LoginActivity.java:36)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
... 11 more

My LoginActivity looks like this (the 36th line is the #setContentView):

public class LoginActivity extends SherlockActivity implements AuthCallback<OAuthConsumer> {

    private ProgressDialog progDialog;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
    }

...

Here is my Manifest:

<application
    android:label="@string/app_name"
    android:icon="@drawable/ic_app_launcher"
    android:name=".MainApplication"
    android:theme="@style/MainAppTheme">

    <activity
        android:name=".ui.SplashActivity"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.Sherlock.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

    <activity
        android:name=".ui.LoginActivity"
        android:windowSoftInputMode="adjustPan|stateHidden"
        android:screenOrientation="portrait"/>
...

And finally my style.xml:

<style name="MainAppTheme" parent="@style/Theme.Sherlock.Light.DarkActionBar">
    <item name="homeAsUpIndicator">@drawable/back_indicator</item>
...

Notice that the SplashActivity works just fine. When it starts the intent for LoginActivity it crashes. Does the problem come from the inheritance? Anyway I need a custom style, so I am not able to declare @style/Theme.Sherlock.Light.DarkActionBar directly.

voydz avatar Jun 06 '13 13:06 voydz

have you at least tried to use the @style/Theme.Sherlock.Light.DarkActionBar directly, does that work?

dodgex avatar Jun 08 '13 10:06 dodgex

this seem to work, since this is the case for splash activity which is launched before the login activity, and i got no crashes for it

voydz avatar Jun 08 '13 11:06 voydz

This happens to me as well. I changed my styles.xml style name to Theme.Sherlock.Light as it was originally Android:Theme.Light. Having the latter caused crashes, and seems to be affected devices with 2.3.6 or below.

loop avatar Aug 06 '13 20:08 loop

Also happens on Galaxy Tab 7.0 Plus (GT-P6200).

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.MainActivity}: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1815)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
at android.app.ActivityThread.access$500(ActivityThread.java:122)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4123)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
at com.actionbarsherlock.internal.ActionBarSherlockCompat.generateLayout(ActionBarSherlockCompat.java:976)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.installDecor(ActionBarSherlockCompat.java:902)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:836)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:261)
at com.example.MainActivity.onCreate(MainActivity.java:74)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
... 11 more

xiaoli avatar Oct 07 '13 10:10 xiaoli

I experienced the same issue on the XOOM (wifi_hubble) and GT-P7510

xMikeTx avatar Oct 07 '13 11:10 xMikeTx

I also had this problem but I solved it. In my case it was generated because I have two themes.xml files with the style for the actionbar one under values and another under values-v11 and I was trying to use Theme.Sherlock.Light for versions prior honeycomb and Theme.Holo.Light for the rest of them. Once I deleted the v11 themes.xml and just left the one that use Theme.Sherlock.Light that error dissapeared.

nirvik66 avatar Oct 07 '13 11:10 nirvik66

hello , i m using ecllipse 10 with the latest updates and getting error in "Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light' " . Even my 2 month old successfully running projects are now showing me error

DipaliShah avatar Nov 08 '14 09:11 DipaliShah