简体   繁体   中英

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

I'm creating an app using support library v7 appcompat with ActionBar and fragments for using on older Android versions. Everything is working fine so far.

But when I want to use a library (in this case javassist android), my app crashes when it starts.

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

My styles.xml looks like this

<style name="AppBaseTheme" parent="Theme.AppCompat.Light"></style>
<style name="AppTheme" parent="AppBaseTheme"></style>

and my Manifest.xml like this

<application
    android:theme="@style/AppTheme" 
    ... >
    ...
</application>

The library has no definition of any style (I deleted those definitions).

Like I wrote, my app works without that javassist library, but it crashes when I add it to build path.

When I don't use appcompat and use native ActionBar etc, it also works. But this is no solution for me.

I don't know what's going wrong. Any ideas?

Add theme attr to activity in manifest:

<activity
    android:theme="@style/AppTheme" 
    ...>
</activity>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM