[英]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.