资源$ NotFoundException:文件res / drawable / abc_ic_ab_back_material.xml

在解决了一个jdk零值的错误,现在即时通讯面对这一个,我做了一点研究,但似乎我不能到一个地步,这里是日志错误

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) 

我真的很困惑它可以是什么,我readed,不能得到的错误

我的应用程序:gradle是这样的

 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' 

这里是我的风格文件夹

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

和我的主要活动。如果需要的话

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

谢谢

Solutions Collecting From Web of "资源$ NotFoundException:文件res / drawable / abc_ic_ab_back_material.xml"

如果你使用的是Gradle Plugin 2.0,你需要在Gradle中进行修改:

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

如果你正在使用Gradle 1.5,你将使用而不是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" } } 

另请检查:将Android支持库更新为23.2.0会导致错误:XmlPullParserException二进制XML文件行#17 <vector>标记要求viewportWidth> 0 。

Android支持库参考: 支持vectorDrawables和animationvectorDrawables 。

同时更新Android支持依赖关系

 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' 

因为您已经在24.0.2版本中使用了构build工具。

如果以上任何解决scheme不起作用,您可以在Activity中添加下面的行

 static { AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); } 

当然更新你的gradle和appcompat到最新版本。 这个过程在我的情况下工作

我遇到了这个问题在Xamarin.Android与Xamarin.Android.Support.Design 24.0.2。 这是我如何解决它:

添加下面的行到我的应用程序类的OnCreate

 AppCompatDelegate.CompatVectorFromResourcesEnabled = true; 

取代:

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

附:

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

由于这个页面是google android.content.res.Resources$NotFoundException: File res/drawable/的第一个结果android.content.res.Resources$NotFoundException: File res/drawable/ ,我想分享一下,这个exception可能是由你的foo.xml包含不正确的代码引起的。

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

这个xml包含<size android:height="@android:style/Widget.ProgressBar.Horizontal" /> ,它成功编译,但在运行时抛出exception,在不同的应用程序中有所不同。

这些都没有为我工作。 但是这样做了:

更改

android:src="@drawable/your_drawable"

app:srcCompat="@drawable/your_drawable"

好吧,我刚刚解决了我的问题,问题是我的gra out过时了,我的SDK,所以如果有人正在运行这个问题,只要这样做

1.-确保您的库更新为piotrek1543上面说2.如果需要更新您的SDK 3.-更新您的gradle文件(非常重要)只是去项目gradle并添加此

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

然后转到您的应用项目>应用>渐变> graddlewrapper.properties并添加

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

4.-将编译compileSdkVersion更改为24,并将buildToolsVersion“24.0.2”(请确保您的依赖性与SDK一致

玩的开心

我已经尝试了上述所有解决scheme。 没有为我工作。 对我来说唯一的一件事就是把所有的支持库更新到最新版本,因为这个bug已经修复了。 所以我简单地做了下面的事情在gradle文件中; 更新的SDK和支持到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'