我正在以编程方式使用矢量drawable而不是png:
getSupportActionBar().setHomeAsUpIndicator(getResources().getDrawable(R.drawable.ic_navigate_before_black_24dp));
一切正常,但应用程序崩溃在android 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
仍然没有帮助。
答案 0 :(得分:2)
<path>
。有时,当XML文件中的<path>
标记太长时会发生这种情况。 drawable
移至drawable-nodpi
。<强>更新强>