I am observing multiple reports for below crash in the Google Play console for my app.
java.lang.NullPointerException:
at com.reactnativenavigation.bridge.NavigationReactEventEmitter.<init> (NavigationReactEventEmitter.java:17)
at com.reactnativenavigation.react.NavigationReactGateway.onReactContextInitialized (NavigationReactGateway.java:114)
at com.reactnativenavigation.react.NavigationReactGateway.access$000 (NavigationReactGateway.java:24)
at com.reactnativenavigation.react.NavigationReactGateway$ReactNativeHostImpl.onReactContextInitialized (NavigationReactGateway.java:174)
at com.facebook.react.ReactInstanceManager$6.run (ReactInstanceManager.java:1017)
at android.os.Handler.handleCallback (Handler.java:742)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:154)
at android.app.ActivityThread.main (ActivityThread.java:5527)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:629)
I don't know what are the steps to reproduce. Below is the line in code on which the abort is occurring
public NavigationReactEventEmitter(ReactContext reactContext) {
this.eventEmitter = reactContext.getJSModule(RCTDeviceEventEmitter.class);
}
So, it looks like the reactContext is null but I am not sure why would it be null.
hmm that's really strange. I checked our crash logs and couldn't find a similar crash.
The event emitter is instantiated in onReactContextInitialized, one would assume react context won't be null at this point.
Yes. That confused me also. It is visible in the call stack also that the event emitter in the onReactContextInitialized, so it shouldn't be null which is why I didn't want to just add a null check there.
I experience the same issue with RN 0.50.3 and RNN 1.1.389
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'com.facebook.react.bridge.JavaScriptModule com.facebook.react.bridge.ReactContext.getJSModule(java.lang.Class)' on a null object reference
at com.reactnativenavigation.bridge.NavigationReactEventEmitter.<init>(NavigationReactEventEmitter.java:17)
at com.reactnativenavigation.react.NavigationReactGateway.onReactContextInitialized(NavigationReactGateway.java:114)
at com.reactnativenavigation.react.NavigationReactGateway.access$000(NavigationReactGateway.java:24)
at com.reactnativenavigation.react.NavigationReactGateway$ReactNativeHostImpl.onReactContextInitialized(NavigationReactGateway.java:174)
at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:995)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
since it is not reproducible it could be a race condition. only happens from time to time on startup. looks to me like a RN bug.
Just had this too but only once.
D/ReactNative: CatalystInstanceImpl.runJSBundle()
D/ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
D/ReactNative: ReactInstanceManager.setupReactContext()
D/ReactNative: CatalystInstanceImpl.initialize()
W/unknown:ReactNative: Packager connection already open, nooping.
E/BluetoothAdapter: Bluetooth binder is null
D/ReactNative: ReactInstanceManager.createReactContext()
D/ReactNative: ReactInstanceManager.onReloadWithJSDebugger()
D/ReactNative: ReactInstanceManager.recreateReactContextInBackground()
E/unknown:ReactNative: Unable to display loading message because react activity isn't available
D/FirebasePhoneAuth: initialized
D/ReactNative: Initializing React Xplat Bridge.
D/ReactNative: Initializing React Xplat Bridge before initializeBridge
D/ReactNative: Initializing React Xplat Bridge after initializeBridge
D/ReactNative: CatalystInstanceImpl.runJSBundle()
D/ReactNative: ReactInstanceManager.setupReactContext()
D/ReactNative: CatalystInstanceImpl.initialize()
E/BluetoothAdapter: Bluetooth binder is null
D/ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
D/ReactNative: ReactInstanceManager.tearDownReactContext()
D/ReactNative: CatalystInstanceImpl.destroy() start
W/unknown:ReactNative: Packager connection already open, nooping.
W/unknown:ReactNative: Packager connection already open, nooping.
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.minderapps.minder, PID: 16267
java.lang.NullPointerException: Attempt to invoke virtual method 'com.facebook.react.bridge.JavaScriptModule com.facebook.react.bridge.ReactContext.getJSModule(java.lang.Class)' on a null object reference
at com.reactnativenavigation.bridge.NavigationReactEventEmitter.<init>(NavigationReactEventEmitter.java:17)
at com.reactnativenavigation.react.NavigationReactGateway.onReactContextInitialized(NavigationReactGateway.java:114)
at com.reactnativenavigation.react.NavigationReactGateway.access$000(NavigationReactGateway.java:24)
at com.reactnativenavigation.react.NavigationReactGateway$ReactNativeHostImpl.onReactContextInitialized(NavigationReactGateway.java:174)
at com.facebook.react.ReactInstanceManager$6.run(ReactInstanceManager.java:993)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
D/ReactNative: ReactInstanceManager.createReactContext()
"react-native": "0.54.0"
"react-native-navigation": "^1.1.365
Seeing the same thing on multiple devices (PlayStore reporting). For us we got a report that this happens when users are accessing camera/image storage. We are using package "react-native-image-picker" for that.
java.lang.NullPointerException:
at com.reactnativenavigation.bridge.NavigationReactEventEmitter.<init> (NavigationReactEventEmitter.java:17)
at com.reactnativenavigation.react.NavigationReactGateway.onReactContextInitialized (NavigationReactGateway.java:114)
at com.reactnativenavigation.react.NavigationReactGateway.access$000 (NavigationReactGateway.java:24)
at com.reactnativenavigation.react.NavigationReactGateway$ReactNativeHostImpl.onReactContextInitialized (NavigationReactGateway.java:174)
at com.facebook.react.ReactInstanceManager$5.run (ReactInstanceManager.java:1000)
at android.os.Handler.handleCallback (Handler.java:761)
at android.os.Handler.dispatchMessage (Handler.java:98)
at android.os.Looper.loop (Looper.java:156)
at android.app.ActivityThread.main (ActivityThread.java:6523)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:832)
"react-native": "^0.51.0",
"react-native-navigation": "^1.1.397",
We're using react-native-image-picker too and we face the same issue.
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'com.facebook.react.bridge.JavaScriptModule com.facebook.react.bridge.ReactContext.getJSModule(java.lang.Class)' on a null object reference
at com.reactnativenavigation.bridge.NavigationReactEventEmitter.<init>(NavigationReactEventEmitter.java:17)
at com.reactnativenavigation.react.NavigationReactGateway.onReactContextInitialized(NavigationReactGateway.java:114)
at com.reactnativenavigation.react.NavigationReactGateway.access$000(NavigationReactGateway.java:24)
at com.reactnativenavigation.react.NavigationReactGateway$ReactNativeHostImpl.onReactContextInitialized(NavigationReactGateway.java:174)
at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1000)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6384)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:791)
"react-native": "^0.51.0",
"react-native-navigation": "^1.1.365",
android 7.1.1
Should be resolved by #2976
Most helpful comment
Should be resolved by #2976