Answer the question
In order to leave comments, you need to log in
The application crashes when switching to another Activity, after setting it to a different theme from the main one. How to fix?
Here is the manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.developer.a0002_actionbar" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:name=".AnotherActivity"
android:label="@string/title_activity_another"
android:parentActivityName=".MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.android.developer.a0002_actionbar.MainActivity" />
</activity>
</application>
</manifest>
</activity>
<activity
android:theme="@style/ThemeOverlay.AppCompat.Dark
09-02 15:56:55.561 10335-10335/com.android.developer.a0002_actionbar E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.android.developer.a0002_actionbar, PID: 10335
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.developer.a0002_actionbar/com.android.developer.a0002_actionbar.AnotherActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplBase.onCreate(AppCompatDelegateImplBase.java:112)
at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:148)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:60)
at com.android.developer.a0002_actionbar.AnotherActivity.onCreate(AnotherActivity.java:14)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Answer the question
In order to leave comments, you need to log in
I'm sorry, the problem has been removed, it turns out ThemeOverlay
that Theme
not particularly related things X) But if someone has something useful to add, I'll mark it with solutions =)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question