Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

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

The strange thing: It only happens when the android application was built (and signed) with Jenkins.

When I use the local apk file from eclipse and push it to my device (or emulator), everything works fine

Any ideas?

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

<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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...