ResourcesNotFoundException when resource available (API 22 and 23 devices)

房东的猫 提交于 2019-12-04 20:29:59

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

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.

Replacing the

<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>

with

android:fillColor="#FF1AA186"

fixes it.

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

Raman Sharma

You need to be sure that inside path tag of your vector drawable you are using fill color as hexcode rather then any reference to color file.

For example:

You need to use

android:fillColor="#FFFFaa"

instead of

android:fillColor="@color/colorname"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!