Android 未找到vectordrawables的资源异常

Android 未找到vectordrawables的资源异常,android,android-layout,xml-parsing,android-gradle-plugin,Android,Android Layout,Xml Parsing,Android Gradle Plugin,我以编程方式使用矢量绘图,而不是png,如: getSupportActionBar().setHomeAsUpIndicator(getResources().getDrawable(R.drawable.ic_navigate_before_black_24dp)); 一切正常,但应用程序在安卓4.2及以下版本中崩溃。我得到下面的日志 Caused by: android.content.res.Resources$NotFoundException: at android.conten

我以编程方式使用矢量绘图,而不是png,如:

getSupportActionBar().setHomeAsUpIndicator(getResources().getDrawable(R.drawable.ic_navigate_before_black_24dp));
一切正常,但应用程序在安卓4.2及以下版本中崩溃。我得到下面的日志

Caused by: android.content.res.Resources$NotFoundException: 
at android.content.res.Resources.loadDrawable (Resources.java:2842)
at android.content.res.Resources.getDrawable (Resources.java:1521)
at android.app.Activity.performCreate (Activity.java:5326)
at android.app.Instrumentation.callActivityOnCreate    (Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity  (ActivityThread.java:2218)
Caused by: org.xmlpull.v1.XmlPullParserException: 
at android.graphics.drawable.Drawable.createFromXmlInner (Drawable.java:917)
at android.graphics.drawable.Drawable.createFromXml (Drawable.java:858)
at android.content.res.Resources.loadDrawable (Resources.java:2839)
我使用的是gradle 3.0.1,还添加了

vectorDrawables.useSupportLibrary=true

仍然没有帮助

  • 检查向量可绘制
    。当XML文件中的
    标记太长时,有时会发生这种情况
  • 尝试将图像从
    drawable
    移动到
    drawable nodpi
  • 更新

  • 尝试使用AppCompatResources.getDrawable(view.getContext(),id);什么时候可以拉
  • 检查向量可绘制
    。当XML文件中的
    标记太长时,有时会发生这种情况
  • 尝试将图像从
    drawable
    移动到
    drawable nodpi
  • 更新

  • 尝试使用AppCompatResources.getDrawable(view.getContext(),id);什么时候可以拉

  • 可能是语法。我会努力的。请看这篇文章的公认答案:你必须纠正你的向量可绘制路径,如果可绘制文件夹中显示了可绘制路径,那么清理你的项目可能是语法。我会努力的。请看这篇文章的公认答案:你必须纠正你的向量可绘制路径,如果drawable显示在drawable文件夹中,则使用从官方google material design网站下载的VectorDrawable清理项目am。除三星galaxy s duos、小米笔记2等少数设备外,该应用程序在大多数设备上运行良好。我的res文件夹1中只有两个文件夹。可拉伸的-24@asishrauto因此,创建另一个foldersure@AntonKazakovI使用从谷歌官方材料设计网站下载的vectordrawables。除三星galaxy s duos、小米笔记2等少数设备外,该应用程序在大多数设备上运行良好。我的res文件夹1中只有两个文件夹。可拉伸的-24@asishrauto因此,创建另一个foldersure@AntonKazakov