gpt4 book ai didi

android - 资源可用时出现 ResourcesNotFoundException(API 22 和 23 设备)

转载 作者:行者123 更新时间:2023-11-29 19:01:58 32 4
gpt4 key购买 nike

我只在 API 22 和 23 设备上遇到此崩溃。

(android.content.res.Resources$NotFoundException: File res/drawable/show_empty_state.xml from drawable resource ID #0x7f080156 at android.content.res.Resources.loadDrawableForCookie(Resources.java:2640) at android.content.res.Resources.loadDrawable(Resources.java:2540) at android.content.res.Resources.getDrawable(Resources.java:806) at android.content.Context.getDrawable(Context.java:458) at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:358) at com.myProj.utils.EmptyStateView.setImage(EmptyStateView.java:55) at com.myProj.tab_two.ShowFragment.onCreateView(ShowFragment.java:111) at android.support.v4.app.Fragment.performCreateView(Fragment.java:2261)

资源绝对存在,并且在更高的设备上运行良好。我最近所做的唯一更改是使用 SVG 为 show_empty_state 替换新的矢量图像。我确实看过其他一些相关问题。到目前为止找不到答案。任何帮助表示赞赏。谢谢。

最佳答案

崩溃是因为矢量 Assets 有 gradient 标签用于 <24 台设备。

android:fillColor
Specifies the color used to fill the path. May be a color or, for SDK 24+, a color state list or a gradient color (See GradientColor and GradientColorItem). If this property is animated, any value set by the animation will override the original value. No path fill is drawn if this property is not specified.

替换

<gradient android:endX="45300.0" android:endY="-86698.0"
<android:startX="45300.0" android:startY="-3118.0" android:type="linear">
<item android:color="#FF1AA186" android:offset="0.0"/>
<item android:color="#FF23B899" android:offset="1.0"/>
</gradient>

android:fillColor="#FF1AA186"

修复它。

更好的方法是用 <24 sdk 的非渐变 Assets 替换 Assets 。

关于android - 资源可用时出现 ResourcesNotFoundException(API 22 和 23 设备),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48688593/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com