Android crash / NullPointerException
See original GitHub issueFor some reason, in android release builds on my app (or debug builds if I configure minifyEnabled true for debug buildType) this crashes on this line (I carefully deobfuscated the stack trace, and it’s definitely crashing here - no idea why minify triggers it when it’s not the classic ClassNotFoundException or NoClassDef etc that proguard would normally throw)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: Exception in native call
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.util.HashMap.get(java.lang.Object)' on a null object reference
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at h5.f.r(:218)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at com.facebook.react.uimanager.z0$m.a(:217)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at com.facebook.react.uimanager.z0$a.run(:915)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at com.facebook.react.uimanager.z0.U(:1026)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at com.facebook.react.uimanager.z0.s(:47)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at com.facebook.react.uimanager.z0$j.c(:1086)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at com.facebook.react.uimanager.f.a(:29)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at com.facebook.react.modules.core.g$d.a(:175)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at com.facebook.react.modules.core.a$a$a.doFrame(:85)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:970)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at android.view.Choreographer.doCallbacks(Choreographer.java:796)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at android.view.Choreographer.doFrame(Choreographer.java:727)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at android.os.Handler.handleCallback(Handler.java:938)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at android.os.Handler.dispatchMessage(Handler.java:99)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at android.os.Looper.loop(Looper.java:223)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at android.app.ActivityThread.main(ActivityThread.java:7656)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at java.lang.reflect.Method.invoke(Native Method)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
09-30 22:08:02.832 8709 8709 E unknown:ReactNative: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
And the relevant portion of android/app/build/outputs/mapping/debug/mapping.txt
showing what h5.f.r
is:
com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager -> h5.f:
java.util.HashMap cleanerCallback -> n
java.util.HashMap toBeRemoved -> m
com.facebook.react.uimanager.layoutanimation.LayoutAnimationController mReaLayoutAnimator -> o
java.util.HashMap mPendingDeletionsForTag -> p
134:163:void <init>(com.facebook.react.uimanager.ViewManagerRegistry,com.facebook.react.bridge.ReactApplicationContext) -> <init>
169:178:void updateLayout(int,int,int,int,int,int) -> C
234:235:void publicDropView(android.view.View) -> G
238:250:void dropView(android.view.View) -> n
181:231:void manageChildren(int,int[],com.facebook.react.uimanager.ViewAtIndex[],int[]) -> r
So it’s in ReanimatedNativeHierarchyManager::manageChildren on line 218 - right where mPendingDeletionsForTag
is dereferenced for a .get
with no null check.
I believe that since mPendingDeletionsForTag is initialized to null, and only set to a valid HashMap in one of the constructors but not the other, I must be using the other constructor in my app.
Then when this line is hit, I get a null pointer exception.
I think this whole chunk could be wrapped in an if (mPendingDeletionsForTag != null) { /* ... */ }
_Originally posted by @mikehardy in https://github.com/software-mansion/react-native-reanimated/pull/2437#r719911428_
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (9 by maintainers)
It’s not actually a zip, sorry. It is literally just the .aar file with .zip added to it because GitHub will simply not allow you to attach an .aar (which is…technically a zip 😆 ) but it will allow a .zip. I’ll amend my instructions. You can try
unzip -l react-native-reaniminated-66-hermes.aar.zip
on command line (-l
is just “list”, it’s safe, or should be) to verify if you likeWith sincere apologies I realize the aar I packed up and attached above does not contain the actual class that I fixed in the related PR. Why is that? Because in order to really test the fix I removed those exact classes from the aar and worked on the java file in my own app’s source tree. I got it working then of course forgot to put them back in the AAR I put here. So if anyone tried to use it before, you would have crashed on startup with a NoClassDefFoundError on ReanimatedNativeHierarchyManager.
I’ve put the classes in their rightful home in the AAR here and I’m re-attaching it. I only noticed myself when I went to take my own fix and put it in another app and couldn’t realize why it was crashing !?!. Apologies
react-native-reanimated-66-hermes.aar.zip