Reputation: 1387
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
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
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
Upvotes: 0
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
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