I have ImageView
with app:srcCompat="@drawable/my_app_img"
I get:
android.content.res.Resources$NotFoundException File res/drawable/$my_app_img__0.xml from color state list resource ID #0x7f07000a
on Android 6 and do not get it on 8 and above.
Here is the my_app_img.xml
:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
xmlns:tools="http://schemas.android.com/tools"
android:width="73dp"
android:height="103dp"
android:viewportWidth="73"
android:viewportHeight="103">
<path
android:fillAlpha="0"
android:fillColor="#000000"
android:pathData="M0,0l72.299,0l0,103l-72.299,0z" />
<path android:pathData="M70.379,96.761L40.602,56.464L25.724,77.276C22.268,82.111 22.324,88.62 25.864,93.394L28.417,96.839C31.291,100.714 35.832,103 40.659,103H67.227C70.442,103 72.288,99.345 70.379,96.761Z">
<aapt:attr name="android:fillColor">
<gradient
android:endColor="#FF094EC2"
android:endX="31.7222"
android:endY="68.3161"
android:startColor="#FF005AF4"
android:startX="57.4428"
android:startY="104.487"
android:type="linear"
tools:targetApi="n" />
</aapt:attr>
</path>
<path android:pathData="M68.592,0H38.75C36.254,0 33.907,1.188 32.431,3.199L2.949,43.369C-0.919,48.64 -0.988,55.79 2.778,61.134L19.001,84.156C19.001,80.833 20.044,77.594 21.984,74.895L71.598,5.853C73.355,3.407 71.606,0 68.592,0Z">
<aapt:attr name="android:fillColor">
<gradient
android:endColor="#FF29EEFD"
android:endX="32.6558"
android:endY="31.6712"
android:startColor="#FF2EB3ED"
android:startX="6.53102"
android:startY="64.8591"
android:type="linear" />
</aapt:attr>
</path>
</vector>
Also I use:
vectorDrawables.useSupportLibrary = true
I think the issue is related to the gradient present in the vector drawable.
You have the <aapt:attr name="android:fillColor">
parameter set with a gradient there, and by looking into the documentation it seems that gradients are supported only from SDK 24+
Android vector drawable
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
You could try without a gradient and see if it works.
I was using ImageView
and replaced it by AppCompatImageView
and fixed it so it can be compatible < 24
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With