无法将可绘制对象转换为可绘制对象

Failed to convert drawable into a drawable

我收到错误 "Failed to convert @drawable/12234 into a drawable",其中 12234 是我的图像名称,它位于可绘制文件夹内。

我可以分配其他较小的图像,但是当我尝试分配此图像时出现错误。

这是我的 Imageview 代码 xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" 
    android:layout_height="match_parent">

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView4"
    android:layout_alignParentTop="true"
    android:src="@drawable/12234"
    android:adjustViewBounds="true"
    android:longClickable="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentBottom="true" />

我通过将图像重命名为先有一个字符来解决问题。

已将图像名称从 12234.jpg 更改为 r12234.jpg

根据文档可绘制资源必须满足以下条件:

File-based resource names must contain only lowercase a-z, 0-9, or _.

而且在你的情况下它不能全是数字,它必须至少有一个字母。

在 Adroid Studio 的设计视图中,尝试单击刷新图标,该图标看起来像两个相互面对的弯曲箭头。 这对我有用——我不需要重命名任何东西或重新启动我的电脑。 我是 运行 ver 1.5.1,Marshmallow,API 23.

我已经磕磕绊绊好几个小时了,几乎阅读了所有问题的所有答案,但没有任何效果。最后,我找到了一个有效的解决方案。

我做了什么

  • 在资源管理器中显示 "drawable"
  • 用 i 替换了所有 ı(drawable-hdpı -> drawable-hdpi,重命名 所有文件夹)然后文件夹没有出现在 android studio
  • 仅将 2 个 i 替换为 ı(drawable-hdpi -> drawable-hdpı,重命名 2 个文件夹)之后,所有图像开始出现,最后 我可以添加图片了。