我正在创建一个应用程序,使用支持库v7 appcompat与ActionBar和fragment在旧的Android版本上使用。到目前为止,一切正常。
但是当我想使用一个库(在本例中是javassist android)时,我的应用程序在启动时崩溃了。
"java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity"
我的style .xml看起来像这样
<style name="AppBaseTheme" parent="Theme.AppCompat.Light"></style>
<style name="AppTheme" parent="AppBaseTheme"></style>
和我的Manifest.xml像这样
<application
android:theme="@style/AppTheme"
... >
...
</application>
库没有任何样式的定义(我删除了那些定义)。
就像我写的,我的应用程序工作没有javassist库,但它崩溃时,我把它添加到构建路径。
当我不使用appcompat并使用本机ActionBar等时,它也可以工作。但这对我来说不是解决办法。
我不知道怎么了。什么好主意吗?
为manifest中的activity添加主题属性:
<activity
android:theme="@style/AppTheme"
...>
</activity>