Hello, sometimes I get a crash of Resources$NotFoundException on android API19.
It's related to Vector Drawable, it's not supported in android lower than 5 unless you use a gradle version major than 1.4. Here is a similar issue.
I verified that by changing the gradle version of this library the crash doesn't appear, can you please change gradle version on build.gradle to the latest version (or at least something major than 1.4.0-beta3)?
Seconding @thierryfornetti here. I did run into some issues a while back with the react native's Switch component where the app would crash on API19. Moving to gradle version 2.1.2 solved this.
I'm running into the same issue on API19 as explained above. Can the gradle version used in this project be upgraded?
+1. I've been having this exact same issue too.
anybody solved this?
if you use android studio 3 canary version then you will get this error for the
gradle version(mine was 3.0.0-alpha6).
i opened the project on android studio 2.3.3 and changed the gradle version to 2.3.3 and run the app on api 19/16/25 emulator ...works just fine.
Still happening, totally randomly.
Same here on API level 17:
android.content.res.Resources$NotFoundException File res/drawable/abc_vector_test.xml from drawable resource ID #0x7f020052
Resources.java:1993 android.content.res.Resources.loadDrawable
Resources.java:673 android.content.res.Resources.getDrawable
ContextCompat.java:374 android.support.v4.content.ContextCompat.getDrawable
AppCompatDrawableManager.java:202 android.support.v7.widget.AppCompatDrawableManager.getDrawable
AppCompatDrawableManager.java:190 android.support.v7.widget.AppCompatDrawableManager.getDrawable
AppCompatDrawableManager.java:711 android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup
AppCompatDrawableManager.java:195 android.support.v7.widget.AppCompatDrawableManager.getDrawable
AppCompatDrawableManager.java:190 android.support.v7.widget.AppCompatDrawableManager.getDrawable
AppCompatResources.java:100 android.support.v7.content.res.AppCompatResources.getDrawable
TintTypedArray.java:71 android.support.v7.widget.TintTypedArray.getDrawable
SwitchCompat.java:212 android.support.v7.widget.SwitchCompat.<init>
SwitchCompat.java:189 android.support.v7.widget.SwitchCompat.<init>
SwitchCompat.java:178 android.support.v7.widget.SwitchCompat.<init>
ReactSwitch.java:26 com.facebook.react.views.switchview.ReactSwitch.<init>
ReactSwitchManager.java:58 com.facebook.react.views.switchview.ReactSwitchManager$ReactSwitchShadowNode.measure
YogaNode.java:590 com.facebook.yoga.YogaNode.measure
YogaNode.java:-2 com.facebook.yoga.YogaNode.jni_YGNodeCalculateLayout
YogaNode.java:161 com.facebook.yoga.YogaNode.calculateLayout
ReactShadowNode.java:342 com.facebook.react.uimanager.ReactShadowNode.calculateLayout
UIImplementation.java:768 com.facebook.react.uimanager.UIImplementation.calculateRootLayout
UIImplementation.java:537 com.facebook.react.uimanager.UIImplementation.updateViewHierarchy
UIImplementation.java:526 com.facebook.react.uimanager.UIImplementation.dispatchViewUpdates
UIManagerModule.java:512 com.facebook.react.uimanager.UIManagerModule.onBatchComplete
NativeModuleRegistry.java:77 com.facebook.react.cxxbridge.NativeModuleRegistry$1.onBatchComplete
NativeModuleRegistry.java:135 com.facebook.react.cxxbridge.NativeModuleRegistry.onBatchComplete
CatalystInstanceImpl.java:148 com.facebook.react.cxxbridge.CatalystInstanceImpl$BridgeCallback.onBatchComplete
NativeRunnable.java:-2 com.facebook.react.bridge.queue.NativeRunnable.run
Handler.java:725 android.os.Handler.handleCallback
Handler.java:92 android.os.Handler.dispatchMessage
MessageQueueThreadHandler.java:31 com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage
Looper.java:153 android.os.Looper.loop
MessageQueueThreadImpl.java:196 com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run
Thread.java:838 java.lang.Thread.run
Caused by: org.xmlpull.v1.XmlPullParserException Binary XML file line #17: invalid drawable tag vector
Drawable.java:881 android.graphics.drawable.Drawable.createFromXmlInner
Drawable.java:822 android.graphics.drawable.Drawable.createFromXml
Resources.java:1990 android.content.res.Resources.loadDrawable
Resources.java:673 android.content.res.Resources.getDrawable
ContextCompat.java:374 android.support.v4.content.ContextCompat.getDrawable
AppCompatDrawableManager.java:202 android.support.v7.widget.AppCompatDrawableManager.getDrawable
AppCompatDrawableManager.java:190 android.support.v7.widget.AppCompatDrawableManager.getDrawable
AppCompatDrawableManager.java:711 android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup
AppCompatDrawableManager.java:195 android.support.v7.widget.AppCompatDrawableManager.getDrawable
AppCompatDrawableManager.java:190 android.support.v7.widget.AppCompatDrawableManager.getDrawable
AppCompatResources.java:100 android.support.v7.content.res.AppCompatResources.getDrawable
TintTypedArray.java:71 android.support.v7.widget.TintTypedArray.getDrawable
SwitchCompat.java:212 android.support.v7.widget.SwitchCompat.<init>
SwitchCompat.java:189 android.support.v7.widget.SwitchCompat.<init>
SwitchCompat.java:178 android.support.v7.widget.SwitchCompat.<init>
ReactSwitch.java:26 com.facebook.react.views.switchview.ReactSwitch.<init>
ReactSwitchManager.java:58 com.facebook.react.views.switchview.ReactSwitchManager$ReactSwitchShadowNode.measure
YogaNode.java:590 com.facebook.yoga.YogaNode.measure
YogaNode.java:-2 com.facebook.yoga.YogaNode.jni_YGNodeCalculateLayout
YogaNode.java:161 com.facebook.yoga.YogaNode.calculateLayout
ReactShadowNode.java:342 com.facebook.react.uimanager.ReactShadowNode.calculateLayout
UIImplementation.java:768 com.facebook.react.uimanager.UIImplementation.calculateRootLayout
UIImplementation.java:537 com.facebook.react.uimanager.UIImplementation.updateViewHierarchy
UIImplementation.java:526 com.facebook.react.uimanager.UIImplementation.dispatchViewUpdates
UIManagerModule.java:512 com.facebook.react.uimanager.UIManagerModule.onBatchComplete
NativeModuleRegistry.java:77 com.facebook.react.cxxbridge.NativeModuleRegistry$1.onBatchComplete
NativeModuleRegistry.java:135 com.facebook.react.cxxbridge.NativeModuleRegistry.onBatchComplete
CatalystInstanceImpl.java:148 com.facebook.react.cxxbridge.CatalystInstanceImpl$BridgeCallback.onBatchComplete
NativeRunnable.java:-2 com.facebook.react.bridge.queue.NativeRunnable.run
Handler.java:725 android.os.Handler.handleCallback
Handler.java:92 android.os.Handler.dispatchMessage
MessageQueueThreadHandler.java:31 com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage
Looper.java:153 android.os.Looper.loop
MessageQueueThreadImpl.java:196 com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run
Thread.java:838 java.lang.Thread.run
+1
Sounds like a problem with the Switch component. As I've removed them this problem disappeared.
The gradle version has been changed with commit 48a02b9, changed from 1.1.3 to 2.3.+.
Didn't have time to test it, but it should be solved with version 4.3.0 of this library.
Can we close this one? I'm not even sure this library ever was to blame, I suspect that people assume it is because it has vector in the error.
Ok, I did my test with a tablet with Android API19, these are the result:
I found a way to reproduce this error, it's a very odd sets of operation (login, send chat message, logout, signup with a new account), of course it's a very random error and based on the things you do it can appear in different places for different reasons.
Every time I did a test, I always run a gradlew clean to delete the old app from my pc, close the terminal of React Native and uninstall the app from the tablet, so there shouldn't be any leftovers.
I'm pretty sure back then I could solve the problem by only changing the build:gradle of this library, in the meanwhile I updated a lot of libraries and I changed from React Native 0.38.1 to 0.42.3. Maybe I was wrong back then or maybe the new libraries changed the behaviour, it's hard to say.
I'm sure it's all related to the way React Native merge the gradle version of all the libraries, by manually changing the grade version of your libraries it appears that sometimes can be enough to solve the problem.
This doesn't exactly close the issue, but the grade version now it's updated and that's good, no idea about why with the new version it appears as if the problem can't be solved anymore.
Try applying the suggested changes here https://stackoverflow.com/questions/37615470/support-library-vectordrawable-resourcesnotfoundexception
+1
version: 4.4.2
Os: 4+, 5+, 6+
react native 0.49
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:1953)
at android.content.res.Resources.getDrawable(Resources.java:660)
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.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100)
at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:71)
at android.support.v7.widget.SwitchCompat.<init>(SwitchCompat.java:212)
at android.support.v7.widget.SwitchCompat.<init>(SwitchCompat.java:189)
at android.support.v7.widget.SwitchCompat.<init>(SwitchCompat.java:178)
at com.facebook.react.views.switchview.ReactSwitch.<init>(ReactSwitch.java:26)
at com.facebook.react.views.switchview.ReactSwitchManager.createViewInstance(ReactSwitchManager.java:102)
at com.facebook.react.views.switchview.ReactSwitchManager.createViewInstance(ReactSwitchManager.java:33)
at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:46)
at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:218)
at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:150)
at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.dispatchPendingNonBatchedOperations(UIViewOperationQueue.java:923)
at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:895)
at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:31)
at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:136)
at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:107)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:747)
at android.view.Choreographer.doCallbacks(Choreographer.java:562)
at android.view.Choreographer.doFrame(Choreographer.java:531)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
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:881)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:822)
at android.content.res.Resources.loadDrawable(Resources.java:1950)
at android.content.res.Resources.getDrawable(Resources.java:660)
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.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100)
at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:71)
at android.support.v7.widget.SwitchCompat.<init>(SwitchCompat.java:212)
at android.support.v7.widget.SwitchCompat.<init>(SwitchCompat.java:189)
at android.support.v7.widget.SwitchCompat.<init>(SwitchCompat.java:178)
at com.facebook.react.views.switchview.ReactSwitch.<init>(ReactSwitch.java:26)
at com.facebook.react.views.switchview.ReactSwitchManager.createViewInstance(ReactSwitchManager.java:102)
at com.facebook.react.views.switchview.ReactSwitchManager.createViewInstance(ReactSwitchManager.java:33)
at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:46)
at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:218)
at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:150)
at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.dispatchPendingNonBatchedOperations(UIViewOperationQueue.java:923)
at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:895)
at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:31)
at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:136)
at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:107)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:747)
at android.view.Choreographer.doCallbacks(Choreographer.java:562)
at android.view.Choreographer.doFrame(Choreographer.java:531)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(NativeStart.java)

@BeckZero
Check your APK, see if you have two abc_vector_test.xml, one in res/drawable/abc_vector_test.xml and one in res/drawable-v21/abc_vector_test.xml. That would mean your APK was not built with --no-version-vectors AAPT option, as Android Developers documentation hints to:
Vector Drawables Backward Compatibility Solution
https://developer.android.com/guide/topics/graphics/vector-drawable-resources.html#vector-drawables-backward-solution
For anyone not using Gradle I wrote this AAPT wrapper tool that passes --no-version-vectors to the real AAPT when called with package action (dandar3/android-aapt-wrapper on Github)
I have this crash on a specific device, strangely we dont have two xmls inside my apk.
I have this crash on a specific device, strangely we dont have two xmls inside my apk.
How did you solve this problem? Now I have encountered this mistake.
Not for REACT NATIVE ( but for JAVA ANDROID ? ) but this link keeps popping whenever I search this issue.
Even after enabling
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
And adding the following code in my Application class.
static {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
I was still getting error. Because the problem was something else. The problem was
android:drawable*="" in EditText and also android:background="" in ImageButton
Removing the line from XML and adding the draw able from java code solves the issue.
Hope this helps someone.
Hope to help you, you can check this article, they describe clearly
https://medium.com/@imstudio/android-crash-when-using-vector-drawables-on-pre-lollipop-8bd27152b56f
Has anyone here solved it?
I've found this issue on my app as well, and reported it to Google:
https://issuetracker.google.com/issues/131338438
Can you please consider starring it?
Attached here the original file, as it seems to be a part of the support library.
original.zip
When I've opened it, I've noticed it has a reference to a color, so it might also be the reason to the crash. Look:

Also, I've found the support library usage of this file:

For now, I'm not sure, but I think one possible solution is to just add such resource file into your project, maybe as a fixed one (meaning with a color and not a color reference) :
Or, if you are brave enough, replace it with PNG files:
But then you will have to check later if your app can indeed handle other VectorDrawable files, because I think the whole point of this file is to check if the app handles such resources correctly on the device.
If anyone can test it on the problematic devices, and see if any of those solutions helps, please let me know.
BTW, it is advised not to use setCompatVectorFromResourcesEnabled , as it has its own issues according to the docs:
This feature defaults to disabled, since enabling it can cause issues with memory usage, and problems updating Configuration instances. If you update the configuration manually, then you probably do not want to enable this. You have been warned.
I solve this issue by using below code
ContextCompat.getDrawable(view.getContext(), id);
use this one
AppCompatResources.getDrawable(view.getContext(), id);
this work
@VigneshkumarM And you didn't get this rare bug ever since?
Most helpful comment
Same here on API level 17: