1

我从 Fabric 的 Crashlytics 获得以下数据,描述了 Android API 19 上的以下崩溃。

这是在 AVD (Nexus 4) 上测试的。

    Fatal Exception: android.content.res.Resources$NotFoundException: File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f020052
                 at android.content.res.Resources.loadDrawable(Resources.java:2101)
                 at android.content.res.Resources.getDrawable(Resources.java:700)
                 at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:374)
                 at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:200)
                 at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:188)
                 at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:723)
                 at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193)
                 at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:188)
                 at android.support.design.widget.TabLayout$TabView.<init>(TabLayout.java:1362)
                 at android.support.design.widget.TabLayout.createTabView(TabLayout.java:797)
                 at android.support.design.widget.TabLayout.newTab(TabLayout.java:500)
                 at fr.ayoubdev.rnak.components.tab.TabLayoutManager.addView(TabLayoutManager.java:66)
                 at fr.ayoubdev.rnak.components.tab.TabLayoutManager.addView(TabLayoutManager.java:17)
                 at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren(NativeViewHierarchyManager.java:384)
                 at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(UIViewOperationQueue.java:175)
                 at com.facebook.react.uimanager.UIViewOperationQueue$2.run(UIViewOperationQueue.java:782)
                 at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:829)
                 at com.facebook.react.uimanager.UIViewOperationQueue.access$1500(UIViewOperationQueue.java:44)
                 at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:868)
                 at com.facebook.react.uimanager.GuardedChoreographerFrameCallback.doFrame(GuardedChoreographerFrameCallback.java:32)
                 at com.facebook.react.uimanager.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:131)
                 at android.view.Choreographer$CallbackRecord.run(Choreographer.java:759)
                 at android.view.Choreographer.doCallbacks(Choreographer.java:574)
                 at android.view.Choreographer.doFrame(Choreographer.java:543)
                 at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
                 at android.os.Handler.handleCallback(Handler.java:733)
                 at android.os.Handler.dispatchMessage(Handler.java:95)
                 at android.os.Looper.loop(Looper.java:136)
                 at android.app.ActivityThread.main(ActivityThread.java:5017)
                 at java.lang.reflect.Method.invokeNative(Method.java)
                 at java.lang.reflect.Method.invoke(Method.java:515)
                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                 at dalvik.system.NativeStart.main(NativeStart.java)
    Caused by org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
                 at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:933)
                 at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
                 at android.content.res.Resources.loadDrawable(Resources.java:2097)
                 at android.content.res.Resources.getDrawable(Resources.java:700)
                 at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:374)
                 at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:200)
                 at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:188)
                 at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:723)
                 at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193)
                 at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:188)
                 at android.support.design.widget.TabLayout$TabView.<init>(TabLayout.java:1362)
                 at android.support.design.widget.TabLayout.createTabView(TabLayout.java:797)
                 at android.support.design.widget.TabLayout.newTab(TabLayout.java:500)
                 at fr.ayoubdev.rnak.components.tab.TabLayoutManager.addView(TabLayoutManager.java:66)
                 at fr.ayoubdev.rnak.components.tab.TabLayoutManager.addView(TabLayoutManager.java:17)
                 at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren(NativeViewHierarchyManager.java:384)
                 at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(UIViewOperationQueue.java:175)
                 at com.facebook.react.uimanager.UIViewOperationQueue$2.run(UIViewOperationQueue.java:782)
                 at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:829)
                 at com.facebook.react.uimanager.UIViewOperationQueue.access$1500(UIViewOperationQueue.java:44)
                 at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:868)
                 at com.facebook.react.uimanager.GuardedChoreographerFrameCallback.doFrame(GuardedChoreographerFrameCallback.java:32)
                 at com.facebook.react.uimanager.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:131)
                 at android.view.Choreographer$CallbackRecord.run(Choreographer.java:759)
                 at android.view.Choreographer.doCallbacks(Choreographer.java:574)
                 at android.view.Choreographer.doFrame(Choreographer.java:543)
                 at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
                 at android.os.Handler.handleCallback(Handler.java:733)
                 at android.os.Handler.dispatchMessage(Handler.java:95)
                 at android.os.Looper.loop(Looper.java:136)
                 at android.app.ActivityThread.main(ActivityThread.java:5017)
                 at java.lang.reflect.Method.invokeNative(Method.java)
                 at java.lang.reflect.Method.invoke(Method.java:515)
                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                 at dalvik.system.NativeStart.main(NativeStart.java)

我真的不明白发生了什么。有人可以帮忙吗?

非常感谢,丹尼尔。

4

1 回答 1

2

看看How to use vector drawables in Android API lower 21?

另一种补救措施可能是:

static
{
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
于 2016-10-29T22:10:44.637 回答