Chris H
Chris H

Reputation: 271

Put image in drawable folder?

I put an image in my res/drawable folder, but when I clean and build my project, I receive the error message R cannot be resolved. I don't understand why this happens, what should I do?

Upvotes: 1

Views: 5087

Answers (5)

Chris
Chris

Reputation: 6321

For Android Studio:

  1. Right click on res, new Image Asset
  2. On Asset type choose Action Bar and Tab Icons
  3. Choose the image path
  4. Give your image a name in Resource name
  5. Next->Finish

The image will be saved in the /res/drawable folder!

Upvotes: 0

Raghu Nagaraju
Raghu Nagaraju

Reputation: 3288

Might be you are using android.R.drawable.your_image

Remove android.R from imports. use R.drawable.your_image

Upvotes: 0

Shekhar Chikara
Shekhar Chikara

Reputation: 3822

Check out the following link: http://source.android.com/source/using-eclipse.html

Note: Eclipse sometimes likes to add an "import android.R" statement at the top of your files that use resources, especially when you ask eclipse to sort or otherwise manage imports. This will cause your make to break. Look out for these erroneous import statements and delete them.

After removing the erroneous imports, delete your R.java file and try to clean and build the project again. If the problem still persists, post here.

Upvotes: 3

android developer
android developer

Reputation: 116030

possible causes:

  1. duplicate file names (across all drawables folders) . for example , is there a file named "h1.png" and also "h1.jpg" ?

  2. bad files names . only letters allowed are lowercase english ones , and digits.

  3. hidden files , like those of the OS . on windows , it's probably "Thumb.db" . either delete them , or delete & disable them. linux and mac also have such files , but with different names and usually start with "." .

Upvotes: 1

ρяσѕρєя K
ρяσѕρєя K

Reputation: 132992

Make sure your image name is in small latters and in res/drawable folder.for how we add drawables in our project and supported images formats see docs Drawable Resources

Upvotes: 0

Related Questions