仅在Android Nougat上找不到可绘制资源ID的ColorStateList

仅在Android Nougat上找不到可绘制资源ID的ColorStateList,第1张

概述我在我的Crashlytics中发现了这个错误,看起来它只对具有预览版 Android Nougat的用户而言是崩溃的. 应用程序在启动时崩溃(主要活动). 堆栈跟踪 Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my.domain/com.my.domain.acti 我在我的Crashlytics中发现了这个错误,看起来它只对具有预览版 Android Nougat的用户而言是崩溃的.

应用程序在启动时崩溃(主要活动).

堆栈跟踪

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my.domain/com.my.domain.activitIEs.MainActivity}: androID.content.res.Resources$NotFoundException: Can't find colorStateList from drawable resource ID #0x7f020057   at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2646)   at androID.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)   at androID.app.ActivityThread.-wrap12(ActivityThread.java)   at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)   at androID.os.Handler.dispatchMessage(Handler.java:102)   at androID.os.Looper.loop(Looper.java:154)   at androID.app.ActivityThread.main(ActivityThread.java:6077)   at java.lang.reflect.Method.invoke(Method.java)   at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)   at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:755)Caused by androID.content.res.Resources$NotFoundException: Can't find colorStateList from drawable resource ID #0x7f020057   at androID.content.res.ResourcesImpl.loadcolorStateList(ResourcesImpl.java:840)   at androID.content.res.Resources.loadcolorStateList(Resources.java:998)   at androID.content.res.TypedArray.getcolor(TypedArray.java:447)   at androID.app.Activity.onApplythemeResource(Activity.java:4039)   at androID.vIEw.ContextthemeWrapper.initializetheme(ContextthemeWrapper.java:198)   at androID.vIEw.ContextthemeWrapper.settheme(ContextthemeWrapper.java:140)   at androID.app.Activity.settheme(Activity.java:4009)   at androID.support.v7.app.AppCompatActivity.settheme(AppCompatActivity.java:90)   at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2592)   at androID.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)   at androID.app.ActivityThread.-wrap12(ActivityThread.java)   at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)   at androID.os.Handler.dispatchMessage(Handler.java:102)   at androID.os.Looper.loop(Looper.java:154)   at androID.app.ActivityThread.main(ActivityThread.java:6077)   at java.lang.reflect.Method.invoke(Method.java)   at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)   at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:755)

看起来AndroID Nougat不再支持我在我的应用程序中使用的某种系统颜色?但我不确切知道如何解决它.

编辑

所以我在我的R文件中找到了ID为0x7f020057的资源,这就是它:

public static final int background_splash_gradIEnt=0x7f020057;

我检查了我在哪里使用它,这里是:

<style name="StartingWindowtheme" parent="Apptheme">    <item name="androID:windowBackground">@drawable/background_splash_gradIEnt</item>    <item name="androID:colorBackground">@drawable/background_splash_gradIEnt</item></style>

这是background_splash_gradIEnd xml文件:

<shape xmlns:androID="http://schemas.androID.com/apk/res/androID"><gradIEnt    androID:angle="135"    androID:endcolor="#00d49e"    androID:startcolor="#00bcd4"/></shape>

我仍然不知道为什么这会引起牛轧糖问题.我尝试删除“StartingWindowtheme”样式,应用程序现在可以正常工作,它不再崩溃.但我需要一个更好的解决方案.

编辑2

所以我试图删除这一行:

<item name="androID:colorBackground">@drawable/background_splash_gradIEnt</item>

它有效.好像是androID:colorBackground就是问题所在.

临时修复

由于问题出现在上面提到的行中,仅在Nougat上,我创建了一个values-v24文件夹并删除了那里的行. App现在适用于Nougat,但我希望有更好的解决方案.

解决方法 我发现了问题所在以及如何解决问题.这是解决方案,我会保持简单.

这条线导致了这个问题:

<item name="androID:colorBackground">@drawable/background_splash_gradIEnt</item>

事实证明,你无法在XML中将drawable设置为colorBackground,因此在删除此行后它可以正常工作.

这只在Nougat上崩溃的原因是因为在早期版本中这是可能的.

总结

以上是内存溢出为你收集整理的仅在Android Nougat上找不到绘制资源ID的ColorStateList全部内容,希望文章能够帮你解决仅在Android Nougat上找不到可绘制资源ID的ColorStateList所遇到的程序开发问题。

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

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

原文地址:https://54852.com/web/1135951.html

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

发表评论

登录后才能评论

评论列表(0条)

    保存