简体   繁体   English

Android:java.lang.IllegalStateException:您需要在此活动中使用Theme.AppCompat主题(或后代)

[英]Android: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity

I still got a crash report because of this Exception 由于出现此异常,我仍然收到崩溃报告

java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

I have searched about it, still can't figure it out how to fix this. 我已经搜索过它了,但仍然不知道如何解决。

I have using Theme.AppCompat.Light as base AppTheme. 我已经使用Theme.AppCompat.Light作为基本AppTheme。 Here my style.xml 这是我的style.xml

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/toolbar</item>
    <item name="colorPrimaryDark">@color/toolbar_dark</item>
    <item name="colorAccent">@color/accent</item>
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="actionOverflowButtonStyle">@style/OverFlow</item>
    <item name="searchViewStyle">@style/ActionBarSearchView</item>
    <item name="colorControlActivated">@color/switch_activated</item>
    <item name="colorSwitchThumbNormal">@color/switch_normal</item>
    <item name="android:colorForeground">@color/switch_track</item>
</style>

I only have 1 style.xml inside values folder 我在values文件夹中只有1个style.xml

I'm using crashlytics in my app, I got this problem only from some device, but this is really annoys me. 我在我的应用程序中使用了crashlytics,仅从某些设备上遇到了此问题,但这确实让我很烦。

Is there anyone know hot to fix this? 有谁知道热解决这个问题?

I have done both of things below, but still got a crash report. 我已完成以下两项操作,但仍收到崩溃报告。

You are getting this problem because you have derived one or more of your Activity classes from ActionBarActivity . 之所以出现此问题,是因为您从ActionBarActivity派生了一个或多个Activity类。 You need to either derive from Activity OR you need to use one of the Theme.Appcompat styles for your ActionBar . 您需要从Activity派生, 或者需要为ActionBar使用Theme.Appcompat样式之一。 And make sure you specify the correct android:theme attribute in all your <activity ... /> declarations in your manifest. 并确保在清单中的所有<activity ... />声明中指定正确的android:theme属性。

EDIT: 编辑:

Add android:theme="@style/AppTheme" to the declaration of MainActivity in your app manifest. android:theme="@style/AppTheme"到应用清单中的MainActivity声明中。 And change parent="Theme.AppCompat.Light" to parent="@style/Theme.AppCompat.Light" in res/theme.xml . 并在res/theme.xml parent="Theme.AppCompat.Light"更改为parent="@style/Theme.AppCompat.Light"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.IllegalStateException:您需要在此活动中使用Theme.AppCompat主题(或后代) - java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity 错误:java.lang.IllegalStateException:您需要在此活动中使用Theme.AppCompat主题(或后代) - Error :java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity java.lang.IllegalStateException您需要在此活动中使用Theme.AppCompat主题(或后代) - java.lang.IllegalStateException You need to use a Theme.AppCompat theme (or descendant) with this activity 定制主题android崩溃原因:java.lang.IllegalStateException:您需要在此活动中使用Theme.AppCompat主题(或后代) - Crash with custom theme android Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity java.lang.IllegalStateException:您需要在此活动中使用 Theme.AppCompat 主题(或后代)。 钛 - java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. titanium Firebase java.lang.IllegalStateException:您需要在此活动中使用Theme.AppCompat主题(或后代) - Firebase java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity java.lang.IllegalStateException:此活动需要使用Theme.AppCompat主题(或后代) - java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity 外部库用法-&gt; java.lang.IllegalStateException:您需要在此活动中使用Theme.AppCompat主题(或后代) - external library usage --> java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity 如何解决:java.lang.IllegalStateException:您需要在此活动中使用 Theme.AppCompat 主题(或后代)? - How to resolve: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity? java.lang.IllegalStateException:您需要在 Flutter App 中使用 Theme.AppCompat 主题(或后代)与此活动 - java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity in Flutter App
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM