升级到版本AppCompat后获得AppCompat不支持当前的主题功能异常v22.1.0问题不支持、升级到、异常、版本

2023-09-07 04:58:55 作者:嘿,迩的內褲!

previously我在我的工程材料设计与切换工具栏的目的使用AppCompat与21.1.2版本。但升级到AppCompat v22.1.0后,我的应用程序已经开始工作古怪。我甚至尝试了一些类似如下的解决方案

Previously i was using AppCompat with version 21.1.2 in my project for the purpose of material design toggle with toolbar. But after upgrading to AppCompat v22.1.0, my app has started working weird. I even tried some of the solutions like as follows

<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>

也适用父主题为

Also applying parent theme as

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">

但没有以上的解决方案是没有帮助我。所以,好心请帮我用你的技巧和建议,以解决我的问题,我目前面对的问题。我也张贴我styles.xml和logcat的错误,供大家参考。任何形式的帮助将是对我有帮助。先谢谢了。

But none of the above solutions was not helpful for me. So kindly please help me by your tips and suggestions to overcome my issue which i am currently facing. I am also posting my styles.xml and logcat error for your reference. Any kind of help would be helpful for me. Thanks in advance.

styles.xml

styles.xml

 <style name="MainActivityTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="colorPrimary">@color/white</item>
        <item name="colorPrimaryDark">#F2F2F2</item>
        <item name="android:windowNoTitle">true</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
        <item name="colorControlActivated">@color/yellow</item>
    </style>

logcat的错误:

Logcat Error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sample.app/com.sample.app.activities.MainActivity}: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2413)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
            at android.app.ActivityThread.access$900(ActivityThread.java:175)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5602)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
            at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:360)
            at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
            at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
            at com.sample.app.activities.MainActivity.onCreate(MainActivity.java:24)
            at android.app.Activity.performCreate(Activity.java:5451)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
            at android.app.ActivityThread.access$900(ActivityThread.java:175)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5602)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
            at dalvik.system.NativeStart.main(Native Method)

的java.lang.IllegalArgumentException: AppCompat不支持当前的主题功能

推荐答案

感谢大家的答复。我通过删除线解决了我的问题,我自己

Thank you all for your replies. I solved my issue on my own by removing the line

<item name="android:windowNoTitle">true</item>

由于加入windowNoTitle两次如下发生错误

The error occurred because of adding windowNoTitle two times as follows

<item name="android:windowNoTitle">true</item>
<item name="windowNoTitle">true</item>