简体   繁体   English

android.content.res.Resources$NotFoundException File res/drawable/$my_app_img__0.xml 来自颜色状态列表资源 ID #0x7f07000a

[英]android.content.res.Resources$NotFoundException File res/drawable/$my_app_img__0.xml from color state list resource ID #0x7f07000a

I have ImageView with app:srcCompat="@drawable/my_app_img"ImageViewapp: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 android.content.res.Resources$NotFoundException File res/drawable/$my_app_img__0.xml 来自颜色状态列表资源 ID #0x7f07000a

on Android 6 and do not get it on 8 and above.在 Android 6 上,不要在 8 及更高版本上使用它。

Here is the my_app_img.xml :这是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.我认为这个问题与矢量 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+您在那里设置了带有渐变的<aapt:attr name="android:fillColor">参数,通过查看文档,似乎只有 SDK 24+ 才支持渐变

Android vector drawable Android 矢量可绘制

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可能是一种颜色,或者,对于 SDK 24+,颜色状态列表或渐变颜色

You could try without a gradient and see if it works.您可以尝试不使用渐变,看看它是否有效。

I am having the same problem.我有同样的问题。 The reason I found it seems to be the issue of android grade plugin version .我发现它的原因似乎是android等级插件版本的问题。

Your vector image only supports API 24 or higher.您的矢量图像仅支持 API 24 或更高版本。 Under 3.2.x or below, I changed from device to PNG file under API 24. However, from 3.3.x there is a crash in that part.在 3.2.x 或以下版本,我在 API 24 下从设备更改为 PNG 文件。但是,从 3.3.x 开始,该部分出现崩溃。

Are you using 3.3.x ?您使用的是3.3.x吗?

If so, you can use Are you using 3.2.x or below Or it works well with AndroidX .如果是这样,您可以使用 Are you using 3.2.x or below Or it works well with AndroidX

Alternatively, you can use the Vector only in API version 24 or higher, or use a PNG file in lower versions.或者,您可以仅在 API 版本 24 或更高版本中使用 Vector,或在较低版本中使用 PNG 文件。

I have not found a better way yet.我还没有找到更好的方法。

I hope this helps.我希望这有帮助。

我正在使用ImageView并用AppCompatImageView替换它并修复它以便它可以兼容 < 24

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 异常 android.content.res.Resources$NotFoundException:文件 res/color/selector_tab_blue_white.xml 来自可绘制资源 ID #0x7f0601d8 - Exception android.content.res.Resources$NotFoundException: File res/color/selector_tab_blue_white.xml from drawable resource ID #0x7f0601d8 如何解决android.content.res.Resources $ NotFoundException:从可绘制资源ID#0x7f02008f中解析文件res / drawable / ic_paper_plane.xml? - how to solve android.content.res.Resources$NotFoundException: File res/drawable/ic_paper_plane.xml from drawable resource ID #0x7f02008f? android.content.res.Resources $ NotFoundException异常:来自drawable资源ID的文件res / drawable / my.xml - Exception android.content.res.Resources$NotFoundException: File res/drawable/my.xml from drawable resource ID 引起:android.content.res.Resources $ NotFoundException:来自可绘制资源ID的文件res / drawable / ic_email_black.xml#0x7f02007e - Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_email_black.xml from drawable resource ID #0x7f02007e android.content.res.Resources $ NotFoundException:来自可绘制资源ID#0x7f0200d7的文件res / drawable / ic_customer_toolbar.xml - android.content.res.Resources$NotFoundException: File res/drawable/ic_customer_toolbar.xml from drawable resource ID #0x7f0200d7 android.content.res.Resources $ NotFoundException:与来自xml类型布局资源ID#0x7f0a001d的%s共享文件 - android.content.res.Resources$NotFoundException: File Share with %s from xml type layout resource ID #0x7f0a001d android.content.res.Resources $ NotFoundException:来自xml类型布局资源ID的文件#0x1020014 - android.content.res.Resources$NotFoundException: File from xml type layout resource ID #0x1020014 KitKat specific- android.content.res.Resources $ NotFoundException:来自可绘制资源ID的文件res / drawable / list_selector_white.xml - KitKat specific- android.content.res.Resources$NotFoundException: File res/drawable/list_selector_white.xml from drawable resource ID Android.content.res.Resources $ NotFoundException:资源不是Drawable(颜色或路径): - Android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): android.content.res.Resources $ NotFoundException:资源不是可绘制对象(颜色或路径):TypedValue {t = 0x2 / d = 0x7f010076 a = 2} - android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010076 a=2}
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM