资源可用时,ResourcesNotFoundException(API 22和23设备) [英] ResourcesNotFoundException when resource available (API 22 and 23 devices)

查看:95
本文介绍了资源可用时,ResourcesNotFoundException(API 22和23设备)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I get this crash only on API 22 and 23 devices.


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

(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的新矢量图像。
我确实看过其他一些相关问题。到目前为止找不到答案。任何帮助表示赞赏。谢谢。

The resource is definitely there and it works fine on higher devices. The only recent change i did was replace a new vector image using SVG for show_empty_state. I did look at some other related questions. Could not find an answer so far. Any help is appreciated. Thanks.

推荐答案

崩溃是因为矢量资产具有 gradient 标签用于< 24设备。

The crash was because the vector asset had gradient tag for <24 devices.


android:fillColor

指定用于填充路径的颜色。可能是
颜色,或者对于SDK 24+,是颜色状态列表或渐变颜色(请参阅
GradientColor和GradientColorItem)。如果将此属性设置为动画,则动画设置的任何
值都将覆盖原始值。如果未指定此属性,则不会绘制
路径填充。

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的非渐变资产。

Better would be to replace the asset with a non-gradient one for <24 sdk.

这篇关于资源可用时,ResourcesNotFoundException(API 22和23设备)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆