简体   繁体   English

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

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

I'm getting this error when trying to run my android application. 我试图运行我的Android应用程序时收到此错误。

The strange thing: It only happens when the android application was built (and signed) with Jenkins. 奇怪的是:它只发生在Android应用程序与Jenkins一起构建(和签名)时。

When I use the local apk file from eclipse and push it to my device (or emulator), everything works fine 当我使用eclipse的本地apk文件并将其推送到我的设备(或模拟器)时,一切正常

Any ideas? 有任何想法吗?

Edit: AndroidManifest.xml 编辑:AndroidManifest.xml

<application
    android:name="at.my.test.App"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/MyActionBarTheme" >
    <activity
        android:name="SplashActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@android:style/Theme.Black.NoTitleBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="LoginActivity"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateHidden" >
    </activity>
    <activity
        android:name="MyFirstActivity"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="MySecondActivity"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="MyThirdActivity"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="WebActivity"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="ErrorActivity"
        android:screenOrientation="portrait"
        android:theme="@android:style/Theme.Black.NoTitleBar" >
    </activity>
</application>  

And the themes.xml file: 而themes.xml文件:

<style name="MyActionBarTheme" parent="@style/Theme.AppCompat">

    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="android:homeAsUpIndicator">@drawable/ic_up_arrow</item>
    <item name="android:windowActionBar">true</item>
    <item name="android:windowBackground">@android:color/white</item>
    <item name="android:windowContentOverlay">@null</item>

    <!-- Support library compatibility -->
    <item name="actionBarStyle">@style/MyActionBar</item>
    <item name="homeAsUpIndicator">@drawable/ic_up_arrow</item>

</style>

<!-- ActionBar styles -->
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar">

    <item name="android:background">@color/my_highlight</item>

    <!-- Support library compatibility -->
    <item name="background">@color/my_highlight</item>

</style>

May this will help you to solve your problem. 愿这可以帮助您解决问题。 (I haven't familiar with Jenkins.) Please put this attribute to Activity (in which you used the Actionbar/Drawer) in Manifest (我不熟悉Jenkins。)请将此属性设置为Manifest中的Activity(在其中使用了Actionbar / Drawer)

android:theme="@style/Theme.AppCompat"

styles.xml styles.xml

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

这只发生在android项目资源文件夹中缺少值-21,缺少值18的样式中,或者您不习惯在适当的项目中在Manifest中声明正确的主题。

暂无
暂无

声明:本站的技术帖子网页,遵循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主题(或后代) - 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? 定制主题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 问题与您需要与此活动一起使用Theme.AppCompat主题(或后代)与该活动一起Theme.AppCompat主题(或后代)” - Issue with You need to use a Theme.AppCompat theme (or descendant) with this activity Theme.AppCompat theme (or descendant) with this activity" 如何解决:IllegalStateException:您需要在此活动中使用 Theme.AppCompat 主题(或后代) - How to solve: IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity Robolectric:IllegalStateException:您需要在此活动中使用 Theme.AppCompat 主题(或后代) - Robolectric: IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity 错误:您需要在此活动中使用Theme.AppCompat主题(或后代) - Error: You need to use a Theme.AppCompat theme (or descendant) with this activity java.lang.IllegalArgumentException:您需要将Theme.AppCompat主题(或后代)与设计库一起使用 - java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library 在 android 中具有自定义主题的应用程序,错误:您需要在此活动中使用 Theme.AppCompat 主题(或后代) - app with custom theme in android, error: You need to use a Theme.AppCompat theme (or descendant) with this activity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM