繁体   English   中英

外部库用法-> java.lang.IllegalStateException:您需要在此活动中使用Theme.AppCompat主题(或后代)

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

我正在使用支持库v7 appcompat与ActionBar和片段创建一个应用程序,以便在较旧的Android版本上使用。 到目前为止一切正常。

但是,当我想使用一个库(在本例中为javassist android)时,我的应用程序在启动时崩溃。

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

我的styles.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等时,它也可以工作。 但这对我来说不是解决方案。

我不知道怎么了。 有任何想法吗?

将主题属性添加到清单中的活动:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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