Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml

AndroidAndroid LayoutAndroid StudioGradleAndroid Gradle-Plugin

Android Problem Overview


After solving a JDK zero value error, now I'm facing this one. I did a little research, but it seems I can't get to the point. Here is the log error:

FATAL EXCEPTION: main
 E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{.MainActivity}: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020013
 E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2204)
 E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2254)
 E/AndroidRuntime:     at android.app.ActivityThread.access$600(ActivityThread.java:141)
 E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
 E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:99)
 E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:137)
 E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5069)
 E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method)
 E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:511)
 E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
 E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
 E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method)
 E/AndroidRuntime:  Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020013
 E/AndroidRuntime:     at android.content.res.Resources.loadDrawable(Resources.java:1953)
 E/AndroidRuntime:     at android.content.res.Resources.getDrawable(Resources.java:660)
 E/AndroidRuntime:     at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:354)
 E/AndroidRuntime:     at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193)
 E/AndroidRuntime:     at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:181)
 E/AndroidRuntime:     at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:689)
 E/AndroidRuntime:     at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
 E/AndroidRuntime:     at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77)
 E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:83)
 E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegateImplV7.<init>(AppCompatDelegateImplV7.java:146)
 E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:28)
 E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:41)
 E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:193)
 E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:173)
 E/AndroidRuntime:     at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:511)
 E/AndroidRuntime:     at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
 E/AndroidRuntime:     at .MainActivity.onCreate(MainActivity.java:29)
 E/AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:5104)
 E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1092)
 E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
 E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2254) 
 E/AndroidRuntime:     at android.app.ActivityThread.access$600(ActivityThread.java:141) 
 E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 
 E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:99) 
 E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:137) 
 E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5069) 
 E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method) 
 E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:511) 
 E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
 E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
 E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method) 
 E/AndroidRuntime:  Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
 E/AndroidRuntime:     at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:881)
 E/AndroidRuntime:     at android.graphics.drawable.Drawable.createFromXml(Drawable.java:822)
 E/AndroidRuntime:     at android.content.res.Resources.loadDrawable(Resources.java:1950)
 E/AndroidRuntime:     at android.content.res.Resources.getDrawable(Resources.java:660) 
 E/AndroidRuntime:     at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:354) 
 E/AndroidRuntime:     at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193) 
 E/AndroidRuntime:     at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:181) 
 E/AndroidRuntime:     at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:689) 
 E/AndroidRuntime:     at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186) 
 E/AndroidRuntime:     at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77) 
 E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:83) 
 E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegateImplV7.<init>(AppCompatDelegateImplV7.java:146) 
 E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:28) 
 E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:41) 
 E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:193) 
 E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:173) 
 E/AndroidRuntime:     at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:511) 
 E/AndroidRuntime:     at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71) 
 E/AndroidRuntime:     at .MainActivity.onCreate(MainActivity.java:29) 
 E/AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:5104) 
 E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1092) 
 E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) 
 E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2254) 
 E/AndroidRuntime:     at android.app.ActivityThread.access$600(ActivityThread.java:141) 
 E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 
 E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:99) 
 E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:137) 
 E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5069) 
 E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method) 
 E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:511) 
 E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
 E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
 E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method) 

I'm really confused about what it can be, I read and can't get to the error:

My app:gradle is this:

apply plugin: 'com.android.application'

android {



    compileSdkVersion 23
    buildToolsVersion "24.0.2"




    defaultConfig {

        applicationId "me.me2.com.myapp"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"




    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }






}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'com.android.support:cardview-v7:23.4.0'


    compile 'com.google.firebase:firebase-storage:9.4.0'
    compile 'com.google.firebase:firebase-database:9.4.0'
    compile 'com.google.firebase:firebase-auth:9.4.0'
    compile 'com.firebaseui:firebase-ui-database:0.4.4'


    compile 'com.squareup.picasso:picasso:2.5.2'





}

apply plugin: 'com.google.gms.google-services'

Here is my style folder:

<resources>

    <!-- Base application theme. -->
    <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>
    </style>
    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>
    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

    <style name="Divider">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">1dp</item>
        <item name="android:background">?android:attr/listDivider</item>
    </style>

</resources>

And my mainactivity.class if needed:

public class MainActivity extends AppCompatActivity {

    VideoView videoView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        // VideoView

        videoView = (VideoView) findViewById(R.id.videoview);
        videoView.setVideoURI(Uri.parse("android.resource://"+getPackageName() + "/" +R.raw.video));
        videoView.requestFocus();

        /**
         * Loop
         */
        videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
                videoView.start();
                mp.setLooping(true);

            }
        });




    }

    
    public void Login(View view) {
        Intent intent = new Intent(this, FragmentMain.class); 
        startActivity(intent);

       // finish();

    }

    public void Registro(View view) {
        Intent intent = new Intent(this, Registro.class);
        startActivity(intent);
    }

   



    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

Thanks.

Android Solutions


Solution 1 - Android

IF you're using Gradle Plugin 2.0, you need to make changes in your gradle:

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

If you are using Gradle 1.5 you’ll use instead of previus:

// 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"  
  }  
 }  

Check also: https://stackoverflow.com/questions/35622438/update-android-support-library-to-23-2-0-cause-error-xmlpullparserexception-bin.

Android Support Library Ref.: Support Vector Drawables and Animated Vector Drawables.

Also update Android Support dependencies from

compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'

to

compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'

as you're already using build-tools in version of 24.0.2.

Solution 2 - Android

If any of the other solutions does not work, you can add this line in your Activity

static {
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}

and of course, update your gradle and appcompat to the latest versions. This worked in my case.

Solution 3 - Android

None of these worked for me. But this did:

Change

android:src="@drawable/your_drawable"

to

app:srcCompat="@drawable/your_drawable"

Solution 4 - Android

I ran into this issue in Xamarin.Android with Xamarin.Android.Support.Design 24.0.2. Here is how I solved it:

Added the following line to my Application class OnCreate:

AppCompatDelegate.CompatVectorFromResourcesEnabled = true;

Replaced:

var upArrow = ContextCompat.GetDrawable(this, Resource.Drawable.abc_ic_ab_back_material);

With:

var upArrow = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.abc_ic_ab_back_material, null);

Solution 5 - Android

Since this page is the first result of google android.content.res.Resources$NotFoundException: File res/drawable/, I want to share that this exception might caused by your foo.xml contains improper code.

e.g. foo.xml:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:id="@android:id/background">
        <shape>
            <size android:height="@android:style/Widget.ProgressBar.Horizontal" />
            <corners android:radius="5dip" />
            <gradient
                android:startColor="#000000"
                android:centerY="0.75"
                android:angle="270"
                />
        </shape>
    </item>
</layer-list>

This xml contains <size android:height="@android:style/Widget.ProgressBar.Horizontal" /> which compiled successfully but throws exception at Runtime, vary in different app.

Solution 6 - Android

use like this in your Activity:

public class MainActivity extends AppCompatActivity {
    static {
        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
     }
  ...
}

and this in your build.gradle :

android {
    ...

     defaultConfig {
         ....
         vectorDrawables.useSupportLibrary = true
    }

}

and in your xml:

app:srcCompat="@drawable/your_icon"

Solution 7 - Android

For me the issue was while running the app on Kitkat version I got this runtime crash.

Issue:

android {
    compileSdkVersion 28
    defaultConfig {
        //Change this to true to enable multidex support for Kitkat
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true

    }

Solution: //comment the line of vector support

android {
        //Change this to true to enable multidex support for Kitkat
         multiDexEnabled true
        //vectorDrawables.useSupportLibrary = true

    }

Solution 8 - Android

Ok, i just solved my problem, the problem was my gradle outdated and my sdk , so if anyone is running with this problem just do this steps

1.- Make sure your libs are updated as piotrek1543 says above 2.- Update your sdk if is necesary 3.- Update your gradle files (VERY IMPORTANT) just go to the project gradle and add this

classpath 'com.android.tools.build:gradle:2.1.0'

then go to your app project > app > graddle > graddlewrapper.properties and add

distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip

4.- change your compile compileSdkVersion to 24 and your buildToolsVersion "24.0.2" (MAKE SURE YOUR DEPENDENCES ARE UP TO DATE WITH THE SDK)

Have fun

Solution 9 - Android

I have tried all solutions mentioned above. Nothing worked for me. The only thing worked for me is very simple is to update all support libraries to latest version as this bug has been fixed in it. So i simple did the below thing in gradle file; updated SDK and support to 25.

android {
    compileSdkVersion 25
    buildToolsVersion "25"
  defaultConfig {
        targetSdkVersion 25
   }

}
In dependencies 

    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support:design:25.1.0'
    compile 'com.android.support:recyclerview-v7:25.1.0'

Solution 10 - Android

Not specifically related to your question, but maybe can solve this problem for all that find themselves here while searching for that error.

For me was the problem with SVG file that I have imported into my project. One of the paths in XML has empty pathData and that was causing the crash on some devices like Pixel XL, Samsung Galaxy S7,...

So double check imported XML for an image if you are using SVG as your image source.

Solution 11 - Android

I had this problem.

In your Application class, in the onCreate() method, add:

AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

... and also use AppCompatImageView instead of ImageView.

Ex : BaseApplication.class :

public class BaseApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        //Your other code here...
        AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    }
}

XML :

<androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/yourIvId"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

Solution 12 - Android

In my case, the issue was about using vector drawable. The spec of the test device was Huawei EVA-L19, Android: Marshmallow

Using srcCompat instead of src resolved my problem.

Solution 13 - Android

In my case, the problem was wrong super-type. I added image view dynamically, and used ImageView instead of AppCompatImageView. Choosing the right super class solved the issue.

Solution 14 - Android

I tried all the answers above but no success because of clarity most of the time.

Just do this:

  1. In the launch_background.xml file, replace mipmap with drawable
  2. Copy the icon image that should be your app icon and paste it in the drawable folder

At the end the launch_background.xml file should look like below.

<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/blue" />

    <!-- You can insert your own image assets here -->
    <item>
        <bitmap android:gravity="center" android:src="@drawable/ic_launcher" />
    </item>
</layer-list>

Solution 15 - Android

Changing the kotlin-stdlib dependency from:

implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.0" to

implementation "org.jetbrains.kotlin:kotlin-stdlib:1.2.0" fixed the error.

Solution 16 - Android

in my case the XML contained android:endX that supports from 24 and up.

Solution 17 - Android

If you are using ?attr inside your drawable, this could be the reason of error.

consider replacing it with Vector Drawable so it can be used in all android versions:

Replace

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="?attr/navigationIconColor" />
        </shape>
    </item>
</selector>

With:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="37dp"
    android:height="5dp"
    android:viewportWidth="37"
    android:viewportHeight="5">
  <path
      android:pathData="M2.5,0h32C35.9,0 37,1.1 37,2.5l0,0C37,3.9 35.9,5 34.5,5h-32C1.1,5 0,3.9 0,2.5l0,0C0,1.1 1.1,0 2.5,0z"
      android:fillColor="?attr/navigationIconColor"/>
</vector>

Solution 18 - Android

The above methods didn’t work for me. I solved it by adding image of every size and used android:src as well it worked. See the answer here https://stackoverflow.com/a/64537207/11669081

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
Questionuser6099735View Question on Stackoverflow
Solution 1 - Androidpiotrek1543View Answer on Stackoverflow
Solution 2 - AndroidashrafulView Answer on Stackoverflow
Solution 3 - AndroidonoView Answer on Stackoverflow
Solution 4 - AndroidpnavkView Answer on Stackoverflow
Solution 5 - Android林果皞View Answer on Stackoverflow
Solution 6 - AndroidAissaDevLabView Answer on Stackoverflow
Solution 7 - AndroidPrajwal WaingankarView Answer on Stackoverflow
Solution 8 - Androiduser6099735View Answer on Stackoverflow
Solution 9 - AndroidGooglerView Answer on Stackoverflow
Solution 10 - AndroidBVanturView Answer on Stackoverflow
Solution 11 - AndroidAceStanView Answer on Stackoverflow
Solution 12 - AndroidSamiAzarView Answer on Stackoverflow
Solution 13 - AndroidMadina SaidovaView Answer on Stackoverflow
Solution 14 - AndroidPeterKapenaPeterView Answer on Stackoverflow
Solution 15 - AndroidvovahostView Answer on Stackoverflow
Solution 16 - Androidsajad abbasiView Answer on Stackoverflow
Solution 17 - AndroidMorteza RastgooView Answer on Stackoverflow
Solution 18 - Androidsai Pavan KumarView Answer on Stackoverflow