java. Lang. IllegalStateException: you need to use theme. In this activity Appcompat theme (or descendants)

I received this error while trying to run my Android application

Oddly enough: it only happens when Android applications are built (and signed) with Jenkins

When I use eclipse's local APK file and push it to my device (or emulator), everything works

Any ideas?

Edit: androidmanifest In 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 themes XML file:

<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>

Solution

I hope this can help you solve the problem (I'm not familiar with Jenkins.) Please set this property to activity in manifest (where actionbar / drawer is used)

android:theme="@style/Theme.AppCompat"
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>