Errol Green
Errol Green

Reputation: 1387

Failed to convert drawable into a drawable

I'm getting the error "Failed to convert @drawable/12234 into a drawable" where 12234 is my image name, that is placed inside the drawable folder.

I'm able to assign other images that are smaller, however when I try to assign this image it gives me an error.

Here is my code for my 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" />

Upvotes: 1

Views: 7500

Answers (4)

Benyam Ephrem
Benyam Ephrem

Reputation: 456

According to documentation drawables resources must satisfy the following:

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

And also in your case it cannot be all numbers, it has to have at least one letter.

Upvotes: 11

Ali Eren &#199;elik
Ali Eren &#199;elik

Reputation: 259

I have been stumbling for many hours, read almost all answers on all questions but nothing worked. Finally, I have found a solution that worked.

What i did

  • Showed "drawable" in explorer
  • Replaced ALL ı's with i's (drawable-hdpı -> drawable-hdpi, renamed all folders) Then the folders didn't appear in android studio
  • Replaced only 2 i's with ı's (drawable-hdpi -> drawable-hdpı, renamed 2 folders) Afterwards, all the images started to appear and finally i was able to add images.

Upvotes: 0

John Chinnici
John Chinnici

Reputation: 1

In Adroid Studio's Design View, try just clicking the refresh icon, the one that looks like two curved arrows facing each other. This worked for me - I didn't need to rename anything or restart my computer. I'm running ver 1.5.1, Marshmallow, API 23.

Upvotes: 0

Errol Green
Errol Green

Reputation: 1387

I solved the issue by renaming the image to have a character first.

Changed image name from 12234.jpg to r12234.jpg

Upvotes: 0

Related Questions