invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.7k stars 2.22k forks source link

[🐛] java.lang.ExceptionInInitializerError on Background Notification in quit state. #7809

Closed Samykills closed 5 months ago

Samykills commented 5 months ago

Issue

Android api 33 When app is in quit state, only on android i receive the following error on logcat, and notification is not shown.

The app works well for foreground and Background notifications in NON-quit state.

Here is the android log -

 FATAL EXCEPTION: main
 Process: com.xyz.my.dev, PID: 14746
  java.lang.ExceptionInInitializerError
   at com.facebook.react.bridge.Arguments.createMap(Arguments.java:163 undefined)
   at io.invertase.firebase.messaging.ReactNativeFirebaseMessagingSerializer.remoteMessageToWritableMap(ReactNativeFirebaseMessagingSerializer.java:69 undefined)
   at io.invertase.firebase.messaging.ReactNativeFirebaseMessagingHeadlessService.getTaskConfig(ReactNativeFirebaseMessagingHeadlessService.java:24 undefined)
   at com.facebook.react.HeadlessJsTaskService.onStartCommand(HeadlessJsTaskService.java:47 undefined)
   at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4921 undefined)
                                                                                                        at android.app.ActivityThread.-$Nest$mhandleServiceArgs(Unknown Source:0)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2310 undefined)
   at android.os.Handler.dispatchMessage(Handler.java:106 undefined)
   at android.os.Looper.loopOnce(Looper.java:211 undefined)
   at android.os.Looper.loop(Looper.java:300 undefined)
   at android.app.ActivityThread.main(ActivityThread.java:8294 undefined)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580 undefined)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1028 undefined)
                                                                                                    Caused by: java.lang.IllegalStateException: SoLoader.init() not yet called
   at com.facebook.soloader.SoLoader.assertInitialized(SoLoader.java:1273 undefined)
   at com.facebook.soloader.SoLoader.loadLibraryOnNonAndroid(SoLoader.java:917 undefined)
   at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:882 undefined)
   at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:869 undefined)
   at com.facebook.react.bridge.ReactBridge.staticInit(ReactBridge.java:34 undefined)
   at com.facebook.react.bridge.NativeMap.<clinit>(NativeMap.java:17 undefined)

Formatted by https://st.elmah.io

Project Files

package json

 "dependencies": {
    "@bam.tech/react-native-image-resizer": "3.0.7",
    "@intercom/intercom-react-native": "7.1.1",
    "@invertase/react-native-apple-authentication": "2.3.0",
    "@notifee/react-native": "7.8.2",
    "@react-native-async-storage/async-storage": "1.22.2",
    "@react-native-camera-roll/camera-roll": "7.4.2",
    "@react-native-clipboard/clipboard": "1.13.2",
    "@react-native-community/netinfo": "11.3.0",
    "@react-native-community/toolbar-android": "0.2.1",
    "@react-native-firebase/analytics": "20.0.0",
    "@react-native-firebase/app": "20.0.0",
    "@react-native-firebase/dynamic-links": "20.0.0",
    "@react-native-firebase/in-app-messaging": "20.0.0",
    "@react-native-firebase/messaging": "20.0.0",
    "@react-native-firebase/remote-config": "20.0.0",
    "@react-native-masked-view/masked-view": "0.3.1",
    "@react-native-picker/picker": "2.6.1",
    "@react-navigation/bottom-tabs": "6.5.14",
    "@react-navigation/material-top-tabs": "6.6.8",
    "@react-navigation/native": "6.1.12",
    "@react-navigation/native-stack": "6.9.20",
    "@react-navigation/stack": "6.3.23",
    "@reduxjs/toolkit": "2.2.3",
    "@sendbird/chat": "4.11.3",
    "@sendbird/uikit-chat-hooks": "3.4.2",
    "@sendbird/uikit-react-native": "3.4.2",
    "@sentry/react-native": "5.22.1",
    "@storybook/react-native": "5.3.25",
    "axios": "0.22.0",
    "date-fns": "2.29.0",
    "formik": "2.4.5",
    "geolib": "3.3.4",
    "i18next": "23.10.0",
    "i18next-async-storage-backend2": "2.0.3",
    "i18next-chained-backend": "4.6.2",
    "i18next-locize-backend": "6.4.1",
    "inversify": "6.0.2",
    "jwt-decode": "2.2.0",
    "lodash": "4.17.21",
    "lottie-react-native": "6.6.0",
    "moment": "2.30.1",
    "moment-timezone": "0.5.45",
    "qs": "6.11.2",
    "react": "18.2.0",
    "react-i18next": "14.0.5",
    "react-native": "0.74.1",
    "react-native-actions-sheet": "0.9.2",
    "react-native-add-calendar-event": "5.0.0",
    "react-native-audio-recorder-player": "3.6.6",
    "react-native-avoid-softinput": "5.0.0",
    "react-native-calendar-events": "2.2.0",
    "react-native-calendars": "1.1304.0",
    "react-native-collapsible": "1.6.1",
    "react-native-config": "1.5.1",
    "react-native-country-picker-modal": "2.0.0",
    "react-native-create-thumbnail": "2.0.0",
    "react-native-date-picker": "4.3.7",
    "react-native-device-info": "10.13.1",
    "react-native-document-picker": "9.1.1",
    "react-native-fast-image": "8.6.3",
    "react-native-fbsdk-next": "12.1.4",
    "react-native-file-access": "3.0.5",
    "react-native-geolocation-service": "5.3.1",
    "react-native-gesture-handler": "2.15.0",
    "react-native-get-random-values": "1.10.0",
    "react-native-health": "1.18.0",
    "react-native-image-picker": "7.1.1",
    "react-native-linear-gradient": "2.8.3",
    "react-native-maps": "1.15.1",
    "react-native-masked-text": "1.13.0",
    "react-native-modal": "13.0.1",
    "react-native-otp-verify": "1.1.8",
    "react-native-pager-view": "6.2.3",
    "react-native-parsed-text": "0.0.22",
    "react-native-permissions": "4.1.5",
    "react-native-phone-input": "1.3.7",
    "react-native-picker-select": "9.0.1",
    "react-native-read-more-text": "1.1.2",
    "react-native-reanimated": "3.9.0-rc.1",
    "react-native-safe-area-context": "4.10.0-rc.2",
    "react-native-screens": "3.29.0",
    "react-native-share": "10.0.2",
    "react-native-skeleton-placeholder": "5.2.4",
    "react-native-status-bar-height": "2.6.0",
    "react-native-svg": "15.0.0",
    "react-native-switch-pro": "patch:react-native-switch-pro@npm%3A1.0.5#~/.yarn/patches/react-native-switch-pro-npm-1.0.5-1808c3ca86.patch",
    "react-native-tab-view": "3.5.2",
    "react-native-video": "6.0.0-beta.5",
    "react-native-view-shot": "3.8.0",
    "react-native-webview": "13.8.6",
    "react-redux": "9.1.0",
    "redux-persist": "6.0.0",
    "redux-persist-transform-filter": "0.0.22",
    "reflect-metadata": "0.2.1",
    "rxjs": "7.8.1",
    "sp-react-native-in-app-updates": "1.4.0",
    "url": "0.11.3",
    "uuid": "9.0.1",
    "yup": "1.4.0"
  },

Javascript

Click To Expand

#### `package.json`: ```json # N/A ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // N/A ``` #### `android/app/build.gradle`: ```groovy // N/A ``` #### `android/settings.gradle`: ```groovy // N/A ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` OUTPUT GOES HERE ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [ ] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `e.g. 5.4.3` - **`Firebase` module(s) you're using that has the issue:** - `e.g. Instance ID` - **Are you using `TypeScript`?** - `Y/N` & `VERSION`


Samykills commented 5 months ago

for those who experienced this issue, it turns out my MainApplication.java was missing this line

SoLoader.init(this, /* native exopackage */ false);

in case u missed it on upgrading RN, please add it.

The above error occurs on the following line in WritableMap messageMap = Arguments.createMap(); And Arguments is imported from react sdk, thus whenever a headless js task is run without SOLoader called, the sdk is not initialised and headless task fails.