error: cannot find symbol variable abc_ic_ab_back_mtrl_am_alpha

AndroidAndroid LayoutAndroid StudioDrawableAndroid Resources

Android Problem Overview


I added a Fragment to my Android Studio project using New > Fragment > Fragment (Blank). As a result when I try to run, the project won't compile because it cannot resolve R.drawable.abc_ic_ab_back_mtrl_am_alpha in

toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);

Any ideas how to solve this?

It looks like I also lost access to android:buttonTint

Android Solutions


Solution 1 - Android

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

Solution 2 - Android

It looks like there are no images in raster format anymore because of the vector drawable implementation in the support library. So I put this vector drawable which represents the same arrow as it was in the previous version of support library. Right click on drawable folder, New -> Drawable resource file and paste this xml code:

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24">

    <path
        android:pathData="M0 0h24v24H0z" />
    <path
        android:fillColor="#ffffff"
        android:pathData="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" />
</vector>

Source

For APIs <21 you will have to add these properties into gradle build file:

Gradle Plugin 2.0+

android {  
   defaultConfig {  
     vectorDrawables.useSupportLibrary = true  
    }  
 }

Gradle Plugin 1.5

android {  
   defaultConfig {  
     generatedDensities = []  
  }  

  // This is handled for you by the 2.0+ Gradle Plugin  
  aaptOptions {  
    additionalParameters "--no-version-vectors"  
  }  
 } 

See this blog post for more information.

Solution 3 - Android

In My case, I done like this

final ActionBar ab = mActivity.getSupportActionBar();
             ab.setHomeAsUpIndicator(android.support.v7.appcompat.R.drawable.abc_ic_ab_back_material);

Solution 4 - Android

I had this problem when updated the Android Support Library to version 23.2.0

In my case, I was using a third party library that conflicted.

I switched to the new version of the third party library to solve the problem.

Solution 5 - Android

Sorry that this might not be the answer you're looking for, but this happened to me too just a few minutes ago. I was alerted by Android Studio that there was a newer version of "com.google.android.gms" and "com.android.support" available in my Gradle file - at the time, I was using 8.3.0 for the former and 23.1.1 for the latter, so I updated to 8.4.0 and 23.2.0 and that's when I got the same problem as you, and Android Studio jumped to the values-v11.xml file in the library for AFollestad's Material Dialogs, and it seems that is causing problems because it uses the AppCompat library.

EDIT: Just found this, if you are using material-dialogs check if you're on version 0.8.5.5. If not, upgrade to it.

Recommended Drawable Solutions

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNouvel TravayView Question on Stackoverflow
Solution 1 - AndroidJonView Answer on Stackoverflow
Solution 2 - AndroidflyingAssistantView Answer on Stackoverflow
Solution 3 - Androiduser711023View Answer on Stackoverflow
Solution 4 - AndroidDouglas Nassif Roma JuniorView Answer on Stackoverflow
Solution 5 - AndroidCiaranC94View Answer on Stackoverflow