Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot resolve symbol error for XML reference to drawable in Android Studio in Mac

I'm brand new to Android Studio and fairly new to development, so I might be missing something simple.

I am trying to import the ic_action_search.png from the Action Bar Icon pack. I've downloaded the Action bar Icon pack, selected the 4 directories containing the images (drawable-hdpi, drawable-mdpi, etc) and copied and pasted them into Android studio.

But in my menue_my.xml file I get a

Cannot resolve symbol error

at the line android:icon="@drawable/ic_action_search"

Here is a screenshot of my android studio with the xml file

enter image description here

I added the png's in project mode, and have tried build>clean and build>rebuild with no success.

When viewing the file structure in "Project" or "Packages" the drawable files appear to be there but not when the file structure is viewed from "Android". Also I don't seem to be able to paste the drawable files into the res folder while in viewing the file structure in "Android".

like image 901
TMin Avatar asked Mar 27 '15 02:03

TMin


1 Answers

So the problem seems to have been with my file structure I was using

res/drawable/drawable-hdpi
res/drawable/drawable-mdpi
res/drawable/drawable-xhdpi
res/drawable/drawable-xxhdpi

where I should have been using

res/drawable-hdpi
res/drawable-mdpi
res/drawable-xhdpi
res/drawable-xxhdpi

so that the drawable directories for the various resolutions are siblings to res/drawable, NOT children.

Thanks to this answer https://stackoverflow.com/a/29294374/2779461

like image 92
TMin Avatar answered Sep 30 '22 06:09

TMin