Andy
Andy

Reputation: 347

Action Bar No Resource Found.

I was trying to run the following code from the android studio guide:

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Search, should appear as action button -->
<item android:id="@+id/action_search"
    android:icon="@drawable/ic_action_search"
    android:title="@string/action_search"
    android:showAsAction="ifRoom" />
<!-- Settings, should always be in the overflow -->
<item android:id="@+id/action_settings"
    android:title="@string/action_settings"
    android:showAsAction="never" />

However, for the following code:

android:icon="@drawable/ic_action_search"
android:title="@string/action_search"

It says:

Cannot resolve symbol '@string/action_search' less... (Ctrl+F1) 
Validates resource references inside Android XML files

And that no resource matches the given name.

I am not sure how to make of it. I have googled extensively and these are possible solutions?

  1. Download the image set at "https://developer.android.com/design/downloads/index.html#action-bar-icon-pack". I was unable to find what to download, and where to extract to.

I have tried:

  1. Setting the minSdk to 11 (and 22) in gradle and in manifest
  2. Redoing the project and reading very closely.

If someone could shed some light on this situation I would be very grateful! I have tried doing my own research/ googling/ experimenting but it has come to no avail.

Upvotes: 0

Views: 6608

Answers (2)

Don ec
Don ec

Reputation: 11

C:\Users\user\AndroidStudioProjects\FunFacts\app\src\main\res\values\dimens.xml: Error: In DataSet 'main', no data file for changedFile. This is an internal error in the incremental builds code; to work around it, try doing a full clean build.

Scott Junner on May 12, 2017 If you open the Build menu at the top of AndroidStudio, you will see two options there of interest to you. "Clean Project" and "Rebuild Project". Try those one after the other and see what results you get. Other than that I don't really know.

It works for me.

Upvotes: 1

Markus Rubey
Markus Rubey

Reputation: 5248

You need to create the string value for your action_search reference.

<resources>
    <string name="app_name">My Application</string>
    <string name="edit_message">Enter a message</string>
    <string name="button_send">Send</string>
    <string name="action_settings">Settings</string>
    <string name="action_search">Search</string>
    <string name="title_activity_main">MainActivity</string>
    <string name="title_activity_display_message">My Message</string>
</resources>

To fix your empty reference for your drawables you have to drop an image with the name of your reference like ic_action_search.png in your drawable folder.

Upvotes: 3

Related Questions