TMH
TMH

Reputation: 6246

Why cant Android Studio find certain resources

enter image description hereI'm trying to use the Android drawable ic_menu_start_conversation in my app, yet Android Studio says it can't find it, and aant crashes if I try to build my app. However, if I look in External Librarys > Android API 19 Platform > res > drawable the png is there, and the preview can find it.

Do I need to just make a local copy of this to be able to use it?

Same issues applies for ic_menu_compose and a few others

Upvotes: 1

Views: 1309

Answers (1)

Scott Barta
Scott Barta

Reputation: 80020

If I try to reproduce your problem, I get this error when building (it's buried in a larger error message from AAPT):

Error: Resource is not public. (at 'icon' with value '@android:drawable/ic_menu_start_conversation').

You can find more information on that here:

Is there any way to use not public android resources in my application?

When I tried to override it and use the resource anyway via:

android:icon="@*android:drawable/ic_menu_start_conversation"

It was able to build the project, though the IDE still showed it as an error (angry red underline in the XML) because you're not supposed to use private resources. When I tried running the app in an API 19 emulator, the icon didn't show up. I was quite possibly doing something wrong (though I did make sure my min/target API versions were 19 and my build tools version was 19.0.X), but that points to the fact that using private resources is fragile, and you're better off copying the resource unless you have a really specific reason for not doing so.

Upvotes: 3

Related Questions