Ojonugwa Jude Ochalifu
Ojonugwa Jude Ochalifu

Reputation: 27257

Can't access drawable resource from menu for navigation drawer

Am trying to add icons to a navigation drawer but somehow, I can't access resources in the res/drawable folder.

This is the list of icons I have in my drawable-hdpi folder:

enter image description here

But I can't access any of them using the correct method:

enter image description here

It says cannot resolve the symbol '@drawable/ic_action_user'

This is strange because I have another application open that uses the exact same method and it works fine there.I've tried invalidating cache and restarting Android Studio with no luck.

All I get are the icons in the drawable-v21 folder:

enter image description here

enter image description here

Upvotes: 0

Views: 1906

Answers (6)

subrahmanyam boyapati
subrahmanyam boyapati

Reputation: 2878

You have created drawable-hdpi folder inside drawable.
You should move it to res folder .

Upvotes: 3

IntelliJ Amiya
IntelliJ Amiya

Reputation: 75788

You need to put images in drawable folder instead of drawable-v21. Create below drawable folder under res .

drawable-ldpi

drawable-mdpi

drawable-hdpi

drawable-xhdpi

drawable-xxhdpi

Then Clean & Rebuild your Project . Hope this helps .

You can check #SO How to import set of icons into Android Studio project

Upvotes: 1

Ahmed Elgendy
Ahmed Elgendy

Reputation: 1700

Try to put your images in the main drawable directory (res/drawable).. Not in the sub one (res/drawable-hdpi)

Upvotes: 0

Deepak John
Deepak John

Reputation: 967

you might have set min sdk version to 21 in gradle, set it to below version or copy all drawables in drawables-hdpi to drawables-v21, as only drawables in drawables-v21 will be used in versions equal to and above 21

Upvotes: 0

nick_kryloff
nick_kryloff

Reputation: 126

Try to use gradle task 'clean' and rebuild project

Upvotes: 1

S Sathiya
S Sathiya

Reputation: 47

First check that the icons is available in your resources folder.

Upvotes: 0

Related Questions