Android Studio Error “AppCompat does not support t

2019-09-20 00:17发布

问题:

This question already has an answer here:

  • Upgraded to AppCompat v22.1.0 and now getting IllegalArgumentException: AppCompat does not support the current theme features 4 answers

So I believe this a common issue with v22 but the current solutions don't seem to be solving my error. I tried setting android:windowActionBar to false and android:windowNoTitle to true but this doesn't seem to help.

Here is my Error Message

05-13 07:33:50.943: E/AndroidRuntime(14440): FATAL EXCEPTION: main
05-13 07:33:50.943: E/AndroidRuntime(14440): Process: com.commonsware.lorem, PID: 14440
05-13 07:33:50.943: E/AndroidRuntime(14440): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.commonsware.lorem/com.commonsware.lorem.Lorem}: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
05-13 07:33:50.943: E/AndroidRuntime(14440):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198)
05-13 07:33:50.943: E/AndroidRuntime(14440):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
05-13 07:33:50.943: E/AndroidRuntime(14440):    at android.app.ActivityThread.access$800(ActivityThread.java:139)
05-13 07:33:50.943: E/AndroidRuntime(14440):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
05-13 07:33:50.943: E/AndroidRuntime(14440):    at android.os.Handler.dispatchMessage(Handler.java:102)
05-13 07:33:50.943: E/AndroidRuntime(14440):    at android.os.Looper.loop(Looper.java:136)
05-13 07:33:50.943: E/AndroidRuntime(14440):    at android.app.ActivityThread.main(ActivityThread.java:5097)
05-13 07:33:50.943: E/AndroidRuntime(14440):    at java.lang.reflect.Method.invokeNative(Native Method)
05-13 07:33:50.943: E/AndroidRuntime(14440):    at java.lang.reflect.Method.invoke(Method.java:515)
05-13 07:33:50.943: E/AndroidRuntime(14440):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
05-13 07:33:50.943: E/AndroidRuntime(14440):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
05-13 07:33:50.943: E/AndroidRuntime(14440):    at dalvik.system.NativeStart.main(Native Method)
05-13 07:33:50.943: E/AndroidRuntime(14440): Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
05-13 07:33:50.943: E/AndroidRuntime(14440):    at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:360)
05-13 07:33:50.943: E/AndroidRuntime(14440):    at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
05-13 07:33:50.943: E/AndroidRuntime(14440):    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
05-13 07:33:50.943: E/AndroidRuntime(14440):    at com.commonsware.lorem.Lorem.onCreate(Lorem.java:35)
05-13 07:33:50.943: E/AndroidRuntime(14440):    at android.app.Activity.performCreate(Activity.java:5248)
05-13 07:33:50.943: E/AndroidRuntime(14440):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
05-13 07:33:50.943: E/AndroidRuntime(14440):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)

Here is my styles.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="android:windowActionBar">false</item>
        <item name="android:windowNoTitle">true</item>
    </style>

</resources>

Maybe I'm just inputting the code wrong so hopefully someone can guide me on what is going wrong. Thank you for your time.

EDIT: I get it that this question has been asked before but all the current solutions are not solving my problem. My question hasn't been answered and the links are not helping.

回答1:

Remove android prefixes and extend your base theme.

Remember: AppCompat does not need android prefixes!

<style name="AppTheme.NoActionBar" parent="AppTheme">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>