[英]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. 我正在使用支持库v7 appcompat与ActionBar和片段创建一个应用程序,以便在较旧的Android版本上使用。 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. 但是,当我想使用一个库(在本例中为javassist android)时,我的应用程序在启动时崩溃。
"java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity"
My styles.xml looks like this 我的styles.xml看起来像这样
<style name="AppBaseTheme" parent="Theme.AppCompat.Light"></style>
<style name="AppTheme" parent="AppBaseTheme"></style>
and my Manifest.xml like this 和我的Manifest.xml这样
<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. 就像我写的一样,我的应用程序在没有该Javassist库的情况下仍然可以工作,但是当我将其添加到构建路径时会崩溃。
When I don't use appcompat and use native ActionBar etc, it also works. 当我不使用appcompat和使用本机ActionBar等时,它也可以工作。 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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.