Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: cannot find symbol variable abc_ic_ab_back_mtrl_am_alpha

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

like image 834
Nouvel Travay Avatar asked Feb 25 '16 16:02

Nouvel Travay


People also ask

How to solve error cannot find symbol?

List class without declaring the corresponding import, therefore the cannot find symbol error occurs. Adding the missing import statement (line 4 in Fig. 4(b)) solves the problem.

What does cannot find symbol error mean?

Any error that starts "cannot find symbol" means that the compiler doesn't know what that symbol (which can be a variable or a class name) refers to. In the second line of the error, where it says "symbol: class Scanner", that indicates that it doesn't know what the Scanner class is.

Can t find symbol Java?

The "Cannot find symbol" errors generally occur when you try to reference an undeclared variable in your code. A "Cannot find symbol" error means that the compiler cannot do this. Your code appears to be referring to something that the compiler doesn't understand.


2 Answers

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

like image 52
Jon Avatar answered Sep 25 '22 13:09

Jon


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.

like image 39
flyingAssistant Avatar answered Sep 21 '22 13:09

flyingAssistant