android– 在Lollipop设备上使用AppCompat-21崩溃

android– 在Lollipop设备上使用AppCompat-21崩溃,第1张

概述最近我将我的nexus5升级为Lollipop.我使用AppCompat-21创建了一个应用程序.值-v21下的样式如下<resources><stylename="AppTheme"parent="android:Theme.Material.Light"></style><esources>但是当我运行应用程序时,它崩溃了信息:Causedby:java.lang.I

最近我将我的nexus 5升级为Lollipop.我使用AppCompat-21创建了一个应用程序.值-v21下的样式如下

<resources>    <style name="Apptheme" parent="androID:theme.Material.light">    </style></resources>

但是当我运行应用程序时,它崩溃了信息:

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

这是我的build.gradle:

apply plugin: 'com.androID.application'androID {    compileSdkVersion 21    buildToolsversion "21.1.1"    defaultConfig {        applicationID "geone.businspector"        minSdkVersion 11        targetSdkVersion 21        versionCode 1        versionname "1.0"    }    buildTypes {        release {            runProguard false            proguardfiles getDefaultProguardfile('proguard-androID.txt'), 'proguard-rules.pro'        }    }}dependencIEs {    compile filetree(dir: 'libs', include: ['*.jar'])    compile 'com.androID.support:appcompat-v7:21.0.0'}

它在Lollipop之前的设备下运行良好……

我Google了很多,并没有很好的解决方案.以前有人见过这个吗? ps:我使用的是AndroID Studio 0.8.14,而且我是AndroID Studio的新手.谢谢.

解决方法:

该错误清楚地表明您使用了错误的主题.您正在使用的活动来自androID.support包,这些活动需要一个themeCompat主题,而不是theme.Material.light,它适用于androID.app包中的活动.像这样重写你的主题:

<resources>    <style name="Apptheme" parent="theme.AppCompat">    </style></resources>

而这个错误将消失.

总结

以上是内存溢出为你收集整理的android – 在Lollipop设备上使用AppCompat-21崩溃全部内容,希望文章能够帮你解决android – 在Lollipop设备上使用AppCompat-21崩溃所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1110731.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存