您的位置:首页 > 移动开发

Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant)

2017-05-17 16:13 681 查看
今天碰到了这么一个问题, Caused by: Java.lang.IllegalStateException: You need to use
a Theme.AppCompat theme (or descendant) with this 根据日志,大意是父类用了AppTheme这个主题,这个子类Activity也必须是这个Theme,否则加载这个Activity的时候不知道用父类的Theme还是用子类的Theme。

由于自己在Manifest的application标签中声明了一个自定义的mainthem主题样式,它继承一个我自定义的appthem,

<application
android:name=".LancentApplication"
android:allowBackup="true"
android:icon="@drawable/greatwall_logo"
android:label="@string/app_name"
android:supportsRtl="true"
tools:replace="android:icon"
android:theme="@style/MainTheme">


<style name="MainTheme" parent="AppTheme">


其他的activity也都用这个样式,但是提示登录页面这个错误,我就改了登陆的them,登录页面正常了,但又提示主页面这个错误.依次改了好多,发现改的页面好了,但后面一个页面就不行了.

找了好久终于找到原因了,最后发现原因是在安卓studio的工程中,其他moudle中的style文件中和我自定义继承的appthem同名字的appthem,但这个appthem不是我自己定义的,所以在编译时虚拟机不能识别哪一个appthem是正确的,我就把moudle里的them删除掉,我的工程就正常了.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐