web-dev-qa-db-fra.com

Ressources $ NotFoundException: fichier res/drawable/abc_ic_ab_back_material.xml

Après avoir résolu une erreur de valeur zéro JDK, je suis maintenant confronté à celle-ci. J'ai fait une petite recherche, mais il semble que je ne peux pas aller au but. Voici l'erreur de journal: 

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) 

Je suis vraiment confus sur ce que cela peut être, j'ai lu et je ne peux pas arriver à l'erreur:

Mon application: Gradle est la suivante:

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'

Voici mon dossier de style:

<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>

Et mon mainactivity.class si nécessaire:

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);
    }
}

Merci.

25
user6099735

Si vous utilisez Gradle Plugin 2.0, vous devez apporter des modifications à votre gradle:

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

Si vous utilisez Gradle 1.5, vous utiliserez à la place de 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"  
  }  
 }  

Vérifiez également: Mise à jour de la bibliothèque de support Android sur 23.2.0: Cause: XmlPullParserException ligne de fichier XML binaire # 17 La balise <vector> requiert viewportWidth> 0 .

Bibliothèque de support Android Réf.: Dessins de support vectoriels et Dessins de dessins animés .

Mettez également à jour les dépendances du support Android à partir de 

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.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'

car vous utilisez déjà des outils de compilation dans la version de 24.0.2.

22
piotrek1543

Si l’une des autres solutions ne fonctionne pas, vous pouvez ajouter cette ligne dans votre activité.

static {
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}

et bien sûr, mettez à jour votre version et appcompat avec les dernières versions. Cela a fonctionné dans mon cas.

21
ashraful

Aucun de ceux-ci n'a fonctionné pour moi. Mais cela a:

Changement 

Android:src="@drawable/your_drawable"

à 

app:srcCompat="@drawable/your_drawable"

8
ono

J'ai rencontré ce problème dans Xamarin.Android avec Xamarin.Android.Support.Design 24.0.2. Voici comment je l'ai résolu:

Ajout de la ligne suivante à ma classe d'application OnCreate:

AppCompatDelegate.CompatVectorFromResourcesEnabled = true;

Remplacé:

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

Avec: 

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

Comme cette page est le premier résultat de google Android.content.res.Resources$NotFoundException: File res/drawable/, je tiens à dire que cette exception pourrait être provoquée par votre foo.xml contient un code incorrect .

par exemple. 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>

Ce fichier xml contient <size Android:height="@Android:style/Widget.ProgressBar.Horizontal" /> qui a été compilé avec succès, mais lève une exception à l’exécution, varie d’une application à l’autre.

4
林果皞

utilisez comme ceci dans votre activité: 

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

et ceci dans votre build.gradle: 

Android {
    ...

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

}

et dans votre xml: 

app:srcCompat="@drawable/your_icon"
1
AissaDevLab

Pas spécifiquement lié à votre question, mais peut peut-être résoudre ce problème pour tous ceux qui se trouvent ici tout en recherchant cette erreur.

Pour moi était le problème avec le fichier SVG que j'ai importé dans mon projet. L'un des chemins en XML a pathData vide et était à l'origine du crash de certains périphériques comme Pixel XL, Samsung Galaxy S7, ...

Vérifiez donc le XML importé pour une image si vous utilisez SVG comme source d’image.

1
BVantur

Ok, je viens de résoudre mon problème, le problème était mon diplôme obsolète et mon sdk, donc si quelqu'un tourne avec ce problème, il suffit de suivre cette procédure 

1.- Assurez-vous que vos bibliothèques sont mises à jour comme indiqué par piotrek1543 ci-dessus 2. Mettez à jour votre sdk si nécessaire ce 

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

puis accédez à votre projet> app> graddle> graddlewrapper.properties et ajoutez 

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

4.- changez votre compilation compileSdkVersion en 24 et votre buildToolsVersion "24.0.2" ( ASSUREZ VOS DÉPENDANCES À JOUR AVEC LE SDK )

S'amuser

1
user6099735

J'ai essayé toutes les solutions mentionnées ci-dessus. Rien n'a fonctionné pour moi. La seule chose qui a fonctionné pour moi est très simple: mettre à jour toutes les bibliothèques de support avec la dernière version car ce bogue a été corrigé. Donc, j'ai simplement fait la chose ci-dessous dans le fichier Gradle; SDK mis à jour et support à 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'
1
Googler

dans mon cas, le XML contient Android:endX qui prend en charge à partir de 24 ans.

0
sajad abbasi

Modification de la dépendance kotlin-stdlib à partir de:

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

implementation "org.jetbrains.kotlin:kotlin-stdlib:1.2.0" corrige l'erreur.

0
vovahost