java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process ${myApplicationId}. Make sure to call FirebaseApp.initializeApp(Context) first.
I get notification from server but my App crashes as soon as I get that message. (After I console.log("notification", notification)); I receive this message while debugging and testing my app on mobile phone:
FATAL EXCEPTION: Firebase-FirebaseMessagingService
E/AndroidRuntime( 8691): Process: ${myAppId}, PID: 8691
E/AndroidRuntime( 8691): java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process ${myAppId}. Make sure to call FirebaseApp.initializeApp(Context) first.
E/AndroidRuntime( 8691): at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@17.0.0:234)
E/AndroidRuntime( 8691): at com.google.firebase.messaging.MessagingAnalytics.zza(Unknown Source)
E/AndroidRuntime( 8691): at com.google.firebase.messaging.MessagingAnalytics.logNotificationReceived(Unknown Source)
E/AndroidRuntime( 8691): at com.google.firebase.messaging.FirebaseMessagingService.zzd(Unknown Source)
E/AndroidRuntime( 8691): at com.google.firebase.iid.zzb.run(Unknown Source)
E/AndroidRuntime( 8691): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/AndroidRuntime( 8691): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/AndroidRuntime( 8691): at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source)
E/AndroidRuntime( 8691): at java.lang.Thread.run(Thread.java:818)
W/ActivityManager( 634): Force finishing activity ${myAppId}/.MainActivity
W/ActivityManager( 634): getRunningAppProcesses: caller 10310 does not hold REAL_GET_TASKS; limiting output
W/DropBoxManagerService( 634): Dropping: data_app_crash (1019 > 0 bytes)
V/RNPushNotification( 8691): sendNotification: Bundle[{google.delivered_priority=high, google.sent_time=1560600723749, google.ttl=2419200, google.original_priority=high, userInteraction=false, id=1089807904, google.message_id=0:1560600723761847%01cd96a801cd96a8, notification=Bundle[{body=Now you can use our application, title=Welcom to app}], collapse_key=${myAppId}, foreground=false}]
D/RNPushNotification( 8691): Cannot send to notification centre because there is no 'message' field in: Bundle[{google.delivered_priority=high, google.sent_time=1560600723749, google.ttl=2419200, google.original_priority=high, userInteraction=false, id=1089807904, google.message_id=0:15606007237sad847%01cd9as01cd96a8, notification=Bundle[{body=Now you can use our application, title=Welcom to asd}], collapse_key=com.techlocksmithbid, foreground=false}]
D/ForegroundUtils( 1364): Foreground changed, PID: 1417 UID: 10017 foreground: true
D/ForegroundUtils( 1364): Foreground UID/PID combinations:
D/ForegroundUtils( 1364): UID: 10017 PID: 1417
D/ForegroundUtils( 1364): UID: 10310 PID: 8691
I/OpenGLRenderer( 634): Initialized EGL, version 1.4
D/WindowManager( 634): adjustConfigurationLw, config:{0 1.0 ?mcc?mnc ?locale ?layoutDir sw360dp w360dp h615dp 480dpi nrml long port ?uimode ?night finger -keyb/v/h -nav/v} mLidState:1 mHasDockFeature:false mHasKeyboardFeature:false mHasHallSensorFeature:true config.hardKeyboardHidden:2
V/ActivityManager( 634): Displayed ActivityRecord{9a28214 u0 com.asus.launcher/.search.activity.SmartSearchActivity t3855} Resume. Not First Launch.
W/ActivityManager( 634): getRunningAppProcesses: caller 10310 does not hold REAL_GET_TASKS; limiting output
this is my project setup:
"react": "16.6.3",
"react-native": "0.57.8",
"react-native-push-notification": "^3.1.3",
buildscript {
ext {
googlePlayServicesVersion = "+"
firebaseVersion = "+"
buildToolsVersion = "28.0.3"
minSdkVersion = 19
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
androidMapsUtilsVersion = "0.5+"
}
}
I got exactly the same issue. Did you find any help?
The same to me. I searched in the native code (of this library) and there is no invocation to FirebaseApp.initializeApp
The same to me. I searched in the native code (of this library) and there is no invocation to
FirebaseApp.initializeApp
Where Should i Put This Line in this Library or has anyone resolved this issue
check again how to set FCM in AndroidManifest.xml pls
Can you show AndroidManifest.xml for FCM ?
implementation 'com.google.firebase:firebase-core:17.0.0'
just add this to the build.gradle file (in app folder). Also, check for the meta-data tags, that also seems to be important.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.my_app">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<application
android:name=".MainApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
>
<activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme"
android:screenOrientation="landscape"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustPan"
android:exported="true">
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name"
android:value="MY_APP_NOTIFICATION_CHANNEL"/>
<meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description"
android:value="MY_APP Notification channel used for push notifications from MY_APP"/>
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
<receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>
<service
android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
</manifest>
This solution helped for me https://github.com/wix/react-native-notifications/issues/285#issuecomment-459178520
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.