abc_ic_ab_back_material resource not found in supp

2019-06-16 07:02发布

问题:

After updating android support library 23.2.0 to 23.2.1 there is an error of R.drawable.abc_ic_ab_back_material not found.

What is the updated resource used in version 23.2.1 ?

回答1:

After researching some time I found that in version 23.2.1 google again introduced the drawable R.drawable.abc_ic_ab_back_mtrl_am_alpha which is removed in 23.2.0.

So, changing to R.drawable.abc_ic_ab_back_mtrl_am_alpha from R.drawable.abc_ic_ab_back_material solve my problem.



回答2:

1- Use R.drawable.abc_ic_ab_back_material instead of R.drawable.abc_ic_ab_back_mtrl_am_alpha

2- in your build.gradle add the bellow value:

// Gradle Plugin 2.0+  

android {  
   defaultConfig {  
     vectorDrawables.useSupportLibrary = true  
    }  
 }

3- Use "srcCompat" attr instead of "src" in all xml:

<ImageButton xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/back_button_bar"
      app:srcCompat="@drawable/abc_ic_ab_back_material"/>

don't forget to use another attr resource like this xmlns:app="http://schemas.android.com/apk/res-auto"

4- Add next line in your application class

AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

5- Google recomend copy the R.drawable.abc_ic_ab_back_material and paste in your project.

source: https://android-developers.googleblog.com/2016/02/android-support-library-232.html



回答3:

I had the same problem with my vector drawables. I used image vector drawable importer tool of Android Studio. it makes the object in

res>anydpi>myobject.xml

The problem solved by copying the drawable into

res>drawable

Folder.