File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020016

32,752

Solution 1

I think you need to make changes in your gradle.

// Gradle Plugin 2.0+  
 android {  
   defaultConfig {  
     vectorDrawables.useSupportLibrary = true  
    }  
 }  

You’ll note this new attribute only exists in the version 2.0 of the Gradle Plugin. If you are using Gradle 1.5 you’ll instead use

// Gradle Plugin 1.5  
 android {  
   defaultConfig {  
     // Stops the Gradle plugin's automatic rasterization of vectors
     generatedDensities = []  
  }  
  // Flag to tell aapt to keep the attribute ids around
  // This is handled for you by the 2.0+ Gradle Plugin  
  aaptOptions {  
    additionalParameters "--no-version-vectors"  
  }  
 }  

I found similar question here.

See Support Vector Drawables and Animated Vector Drawables in Android Support Library update. I hope its help you.

Solution 2

As per as the documentation of Google's support library for 24.0.0, they have changed the vector drawable library to what it was before: Added AppCompatDelegate.setCompatVectorFromResourcesEnabled() method to re-enable usage of vector drawables in DrawableContainer objects on devices running Android 4.4 (API level 19) and lower. See AppCompat v23.2 — Age of the vectors! for more information.

I faced the same issue and my SVG statelist drawables used in my project were working just fine till Marshmallow devices.

Later when I got the crash for the same in Android N, I realized that the svgs were a bit corrupted and contained characters like: � and this caused the crash.

But these were not reflected in Android Marshmallow and prior devices.

Make sure your vector drawable doesn't contain any of those characters as the way of parsing has been changed from the library 24.0.0. So vector drawables working fine till Marshmallow might not work in Nougat devices.

Hope this helps :)

Solution 3

I solve this problem by updating my support library from

'com.android.support:appcompat-v7:23.2.0'
'com.android.support:design:23.2.0'

to the same dependencies of 23.2.1.

When I met the problem, I had not made any changes in my module built by Android Studio.

So I was so confused then I tried to update android support library. After updating, please remember to sync your build.gradle

Solution 4

I solved the issue as follows: Try with changing styles.xml to

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

This is because if style requires ActionBar there are chances of not finding abc_back button but with no action bar problem is solved

Solution 5

This worked for me: Replace the com.android.support:design version in build.gradle with one that works. Find which version works by creating a new project from scratch in Android Studio and using the version from that.

I had this problem when I added a Navigation Drawer Activity from the File->New->Activity menu to an older project with Android Studio.

Android Studio added a dependency like so: compile 'com.android.support:design:24.0.0-alpha1' (I'm not sure of the exact version but it had '24' and 'alpha').

I then created a new dummy project, specifying a Navigation Drawer Activity in the new project wizard. I noticed that the new project had a different dependency: compile 'com.android.support:design:23.2.1'

So I took this dependency and put it in the first project, and the problem was solved.

Share:
32,752

Related videos on Youtube

SilentKnight
Author by

SilentKnight

Study the Major of Software Engineering in Wuhan University from Sep, 2009 to Jun, 2013. Android R&amp;D Engineer with the Hero Complex @ Big Data Innovation Centre, CreditEase. Google, or Android Technology Enthusiast exactly. Hollywood Movies, Grammy Music, Basketball Games Lover. English Language and Literature Lover. Loyal Follower of DC Heroes &amp;&amp; Big Fun of Marvel Universe.

Updated on August 14, 2021

Comments

  • SilentKnight
    SilentKnight over 2 years

    Recently android support library was updated to 23.2.0. After downloading android sdk and updating android design support library into 23.2.0, this error happens repeatedly. My project can't even be compiled. The complete error log says:

    03-02 12:00:04.945 9324-9324/com.creditease.zhiwang.debug E/AndroidRuntime: FATAL EXCEPTION: main
            java.lang.RuntimeException: Unable to start activity ComponentInfo{com.creditease.zhiwang.debug/com.creditease.zhiwang.activity.TabContainerActivity}: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020016
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2309)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
            at android.app.ActivityThread.access$700(ActivityThread.java:169)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1330)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5528)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
            at dalvik.system.NativeStart.main(Native Method)
            Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020016
            at android.content.res.Resources.loadDrawable(Resources.java:2974)
            at android.content.res.Resources.getDrawable(Resources.java:1558)
            at android.support.v7.widget.TintResources.superGetDrawable(TintResources.java:48)
            at android.support.v7.widget.AppCompatDrawableManager.onDrawableLoadedFromResources(AppCompatDrawableManager.java:374)
            at android.support.v7.widget.TintResources.getDrawable(TintResources.java:44)
            at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:323)
            at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:180)
            at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173)
            at android.support.v7.widget.ToolbarWidgetWrapper.<init>(ToolbarWidgetWrapper.java:184)
            at android.support.v7.widget.ToolbarWidgetWrapper.<init>(ToolbarWidgetWrapper.java:91)
            at android.support.v7.app.ToolbarActionBar.<init>(ToolbarActionBar.java:74)
            at android.support.v7.app.AppCompatDelegateImplV7.setSupportActionBar(AppCompatDelegateImplV7.java:210)
            at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:119)
            at com.creditease.zhiwang.activity.BaseActivity.initToolBar(BaseActivity.java:300)
            at com.creditease.zhiwang.activity.BaseActivity.initToolBar(BaseActivity.java:265)
            at com.creditease.zhiwang.activity.TabContainerActivity.onCreate(TabContainerActivity.java:107)
            at android.app.Activity.performCreate(Activity.java:5372)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2271)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363) 
            at android.app.ActivityThread.access$700(ActivityThread.java:169) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1330) 
            at android.os.Handler.dispatchMessage(Handler.java:99) 
            at android.os.Looper.loop(Looper.java:137) 
            at android.app.ActivityThread.main(ActivityThread.java:5528) 
            at java.lang.reflect.Method.invokeNative(Native Method) 
            at java.lang.reflect.Method.invoke(Method.java:525) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025) 
            at dalvik.system.NativeStart.main(Native Method) 
            Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
            at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:933)
            at android.graphics.drawable.Drawable.createFromXml(Drawable.java:873)
            at android.content.res.Resources.loadDrawable(Resources.java:2970)
            at android.content.res.Resources.getDrawable(Resources.java:1558) 
            at android.support.v7.widget.TintResources.superGetDrawable(TintResources.java:48) 
            at android.support.v7.widget.AppCompatDrawableManager.onDrawableLoadedFromResources(AppCompatDrawableManager.java:374) 
            at android.support.v7.widget.TintResources.getDrawable(TintResources.java:44) 
            at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:323) 
            at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:180) 
            at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173) 
            at android.support.v7.widget.ToolbarWidgetWrapper.<init>(ToolbarWidgetWrapper.java:184) 
            at android.support.v7.widget.ToolbarWidgetWrapper.<init>(ToolbarWidgetWrapper.java:91) 
            at android.support.v7.app.ToolbarActionBar.<init>(ToolbarActionBar.java:74) 
            at android.support.v7.app.AppCompatDelegateImplV7.setSupportActionBar(AppCompatDelegateImplV7.java:210) 
            at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:119) 
            at com.creditease.zhiwang.activity.BaseActivity.initToolBar(BaseActivity.java:300) 
            at com.creditease.zhiwang.activity.BaseActivity.initToolBar(BaseActivity.java:265) 
            at com.creditease.zhiwang.activity.TabContainerActivity.onCreate(TabContainerActivity.java:107) 
            at android.app.Activity.performCreate(Activity.java:5372) 
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104) 
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2271) 
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363) 
            at android.app.ActivityThread.access$700(ActivityThread.java:169) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1330) 
            at android.os.Handler.dispatchMessage(Handler.java:99) 
            at android.os.Looper.loop(Looper.java:137) 
            at android.app.ActivityThread.main(ActivityThread.java:5528) 
            at java.lang.reflect.Method.invokeNative(Native Method) 
            at java.lang.reflect.Method.invoke(Method.java:525) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025) 
            at dalvik.system.NativeStart.main(Native Method)
    

    This error was thrown by setSupportActionBar(toolbar); whereas it didn't happen at 23.0.1 of android design library 23.2.0. Meanwhile according this log, I guessed this drawable was removed since android design library 23.2.0.

    So, could someone told me why is this happening?

    • Vishnu
      Vishnu about 8 years
      Did you checked the drawable folder if this file exists or not? If this file exists in the drawable folder, make sure that, the file name is all small letters and have no special characters excepts _. Also try to find the place where this resource is used.
    • SilentKnight
      SilentKnight about 8 years
      @cricket_007 Yes, this one: res/drawable/abc_ic_ab_back_material.xml. Obviously, this drawable comes from android design library.
    • SilentKnight
      SilentKnight about 8 years
      @Vishnu I only changed the version of android design library from 23.0.1 to 23.2.0. All resources are OK.
    • OneCricketeer
      OneCricketeer about 8 years
      Well, yeah I can read the logcat. You didn't seem to specify what the "Caused by" line indicated in your question, so I was simply pointing it out
    • SilentKnight
      SilentKnight about 8 years
      @cricket_007 setSupportActionBar(toolbar); this line causes this at present. But, would it and how?
    • OneCricketeer
      OneCricketeer about 8 years
      The full name of the XML file is (roughly, going off android naming scheme) "action bar compat, ice cream, action bar, back button, material"... So, that being said, it's the drawable for the back button on the toolbar, so it makes sense that line triggers the problem
    • wviana
      wviana almost 8 years
      I having same problem in 24.0.0. How did you check the the file on res/drawable/abc_ic_ab_back_material.xml Idk how to get into this path. I'm also using setSupportActionBar
    • wviana
      wviana almost 8 years
      May it have something with AppCompatActivity? Is it ok for using it in newer versions of support library ?
  • Ramesh_D
    Ramesh_D about 8 years
    And you need to use @style/Theme.AppCompat.NoActionBar. to get it run lower version..
  • Victor Pinto
    Victor Pinto about 8 years
    I need to install buildToolsVersion "23.0.3" to work
  • IgorGanapolsky
    IgorGanapolsky about 8 years
    I get an error: Error:(35, 0) Could not find property 'vectorDrawables' on ProductFlavor_Decorated{name=main, dimension=null, minSdkVersion=ApiVersionImpl{mApiLevel=17, mCodename='null'}, targetSdkVersion=ApiVersionImpl{mApiLevel=23, mCodename='null'}
  • Ivelius
    Ivelius almost 8 years
    Doesn't solve the problem for me... Still have Resource not found exception
  • wviana
    wviana almost 8 years
    You saved me. I changes mine into compileSdkVersion 23, compile 'com.android.support:appcompat-v7:23.4.0' and compile 'com.android.support:design:23.4.0'. So I looked for the latest 23 version of appcompat-v7. I was using version 24 but it didn't worked on Android 4.4.4
  • wviana
    wviana almost 8 years
    I've found that my code needs version 24 to work property. So I'm back trying to fix this vector drawable problem. If you get any tip let me know.
  • Emerson Barcellos
    Emerson Barcellos over 7 years
    Essa deveria ser a resposta!!!
  • Vladislav Mikitich
    Vladislav Mikitich over 7 years
    Same issue, gradle 2.1, android libs 24.2.0. I patched gradle config but exception still appears on api19(4.4.4)
  • Akbarsha
    Akbarsha over 7 years
    Great! Thanks for the info. Saved my time
  • Ananya Srivastav
    Ananya Srivastav over 7 years
    in which gradle to make these changes.. in module or project?
  • pRaNaY
    pRaNaY over 7 years
    @Ananya : add in module level gradle into android {..} section.
  • Ananya Srivastav
    Ananya Srivastav over 7 years
    @pRaNaY thanks for the info but the solution for me was to change appcompat version in dependencies and others like compile and targetsdk
  • Parag Kadam
    Parag Kadam over 7 years
    @VictorPinto thanks a lot man it worked after following your suggestion.
  • Vikas Patidar
    Vikas Patidar over 7 years
    @lvelius try adding static code block either in your application or activity class static { AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); }
  • Mr.Moustard
    Mr.Moustard about 7 years
    For me the trick was to add AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); to the onCreate() method.
  • Skyler
    Skyler almost 7 years
    Where did you add AppCompatDelegate.setCompatVectorFromResourcesEnabled()
  • Anirban Bhattacharjee
    Anirban Bhattacharjee almost 7 years
    It should be done before setting the content view. Preferably, in a static block.
  • Konstantin Konopko
    Konstantin Konopko over 6 years
    This doesn't work for me (API 19, 4.4.2). Getting android.content.res.Resources$NotFoundException
  • behrad
    behrad almost 4 years
    Add this line in your Application class AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);