10

So in my project I was using standard material search icon in action bar.

<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item
    android:id="@+id/search"
    android:title="@string/action_search"
    android:icon="@drawable/abc_ic_search_api_mtrl_alpha"
    app:showAsAction="collapseActionView|ifRoom"
    app:actionViewClass="android.support.v7.widget.SearchView" /> </menu>

But if I update libreries from 23.0.1 to 24.1.1 Android Studio says:

Cannot resolve symbol abc_ic_search_api_mtrl_alpha

Why is that? I searched in google but didn't find answer.

piotrek1543
  • 19,130
  • 7
  • 81
  • 94
Personal Jesus
  • 133
  • 2
  • 10

2 Answers2

33

I've found an similar issue on StackOverflow: error: cannot find symbol variable abc_ic_ab_back_mtrl_am_alpha

The answer for topic above is:

The name of the resource was changed in the 23.2.0 support library.

Modify abc_ic_ab_back_mtrl_am_alpha to abc_ic_ab_back_material

Edit: In 23.2.1 the name of the component was changed back to abc_ic_ab_back_mtrl_am_alpha

Edit: In 24.0.0 the name of the component was changed to: abc_ic_ab_back_material

All you need to do is to change name abc_ic_search_api_mtrl_alpha to abc_ic_ab_search_material

It should work

Update

For API version 24.2.1 and greater use below key word.

abc_ic_search_api_material

It will work.

Community
  • 1
  • 1
piotrek1543
  • 19,130
  • 7
  • 81
  • 94
1

You can import the 'back' and 'search' material icons as vector drawables.

Right click res/drawable -> New -> vector asset

You can then customize the color of the drawable using DrawableCompat.setTint(). Not only is this more flexible but it will also no break in future support libraries updates.

mbonnin
  • 6,893
  • 3
  • 39
  • 55