user2273146
user2273146

Reputation: 1622

I cannot build drawable resource file

Suppose If I create a drawable resource file name background_rect_shape and call it from layout i.e. android:background="@drawable/background_rect_shape", Then after when i build my application it shows this error :

Error:(14, 29) No resource found that matches the given name (at 'background' with value '@drawable/background_rect_shape).

Upvotes: 2

Views: 153

Answers (1)

Sachin Aggarwal
Sachin Aggarwal

Reputation: 1135

This error means that R.java does not have a reference to the image file in question. Check R.java under gen folder and find out if it has a location reference to the image file you added. If it does not, these are the possible reasons.

  1. You have added an image file to a wrong drawable folder. There are three drawable directories, namely drawable-hdpi, drawable-ldpi, drawable-mdpi. Try to add image to all three directories and one of them will work depending on the resolution size of your image.

  2. You have another file in the folder with the same name. Rename one of them so that there are no name conflicts.

If it still not works -

1. Try cleaning the project and rebuild again.

Upvotes: 1

Related Questions