OneSignal / react-native-onesignal

React Native Library for OneSignal Push Notifications Service
Other
1.57k stars 374 forks source link

[Bug]: Android release APK crashing #1691

Open usamaabutt opened 7 months ago

usamaabutt commented 7 months ago

What happened?

I am using the latest version of "OneSignal SDK 11" and "RN lib version 5.1.1". My Android release APK is crashing and throwing this error catch through adb logcat '*:W'.

Error:

FATAL EXCEPTION: mqt_native_modules
04-13 16:07:31.557 23027 23152 E AndroidRuntime: Process: com.smile.members, PID: 23027
04-13 16:07:31.557 23027 23152 E AndroidRuntime: java.lang.RuntimeException: Could not invoke OneSignal.addTriggers

Steps to reproduce?

1. Install the `react-native-onesignal` library
2. Initialise the library through `OneSignal.initialize(Config.ONE_SIGNAL_APP_ID);`
3. Create an APK file and install it on a real phone
4. On app launch it's crashing

What did you expect to happen?

I expect the release APK of Android will not crash and will work without crashing.

React Native OneSignal SDK version

Release 5.1.1

Which platform(s) are affected?

Relevant log output

TypeError: null is not an object (evaluating 'f.setupAndStartRecording')
04-13 16:35:06.375 24154 24283 E AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
04-13 16:35:06.375 24154 24283 E AndroidRuntime: Process: com.smile.members, PID: 24154
04-13 16:35:06.375 24154 24283 E AndroidRuntime: java.lang.RuntimeException: Could not invoke OneSignal.addTriggers
04-13 16:35:06.375 24154 24283 E AndroidRuntime:    at com.facebook.react.bridge.JavaMethodWrapper.invoke(Unknown Source:192)
04-13 16:35:06.375 24154 24283 E AndroidRuntime:    at com.facebook.react.bridge.JavaModuleWrapper.invoke(Unknown Source:147)
04-13 16:35:06.375 24154 24283 E AndroidRuntime:    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
04-13 16:35:06.375 24154 24283 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:942)
04-13 16:35:06.375 24154 24283 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:99)
04-13 16:35:06.375 24154 24283 E AndroidRuntime:    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0)
04-13 16:35:06.375 24154 24283 E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:201)
04-13 16:35:06.375 24154 24283 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:288)
04-13 16:35:06.375 24154 24283 E AndroidRuntime:    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source:37)
04-13 16:35:06.375 24154 24283 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:1012)
04-13 16:35:06.375 24154 24283 E AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException
04-13 16:35:06.375 24154 24283 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
04-13 16:35:06.375 24154 24283 E AndroidRuntime:    at com.facebook.react.bridge.JavaMethodWrapper.invoke(Unknown Source:148)
04-13 16:35:06.375 24154 24283 E AndroidRuntime:    ... 9 more
04-13 16:35:06.375 24154 24283 E AndroidRuntime: Caused by: java.lang.Exception: Must call 'initWithContext' before use
04-13 16:35:06.375 24154 24283 E AndroidRuntime:    at com.onesignal.internal.OneSignalImp.getInAppMessages(Unknown Source:16)
04-13 16:35:06.375 24154 24283 E AndroidRuntime:    at com.onesignal.OneSignal.getInAppMessages(Unknown Source:6)
04-13 16:35:06.375 24154 24283 E AndroidRuntime:    at com.onesignal.rnonesignalandroid.RNOneSignal.addTriggers(Unknown Source:0)
04-13 16:35:06.375 24154 24283 E AndroidRuntime:    ... 11 more

Code of Conduct

jennantilla commented 7 months ago

Hello @usamaabutt thank you for your patience! I see in the stack trace that the method addTriggers is mentioned. When/where are you calling this method in your code? Would you be able to provide the full logs reproducing this crash so we can take a closer look?

Appreciate it!

Tatobarbosa commented 4 months ago

I'm having the same problem after updating from react-native-onesignal 4.5.0 to react-native-onesignal 5.2.2.

I'm not calling addTriggers anywhere in my code. And the OneSignal.initialize(ONESIGNAL_APP_KEY); is being called on the top of App.tsx

Its happening everytime i try to start the app, even when running development mode.