question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

App Crashes when receiving new FCM notification

See original GitHub issue

Was trying to migrate from GCM to FCM, so upgraded to the latest version and changed the implementation to hook up FCM as specified in the instructions. However, when sending a notification message from the firebase console, app is crashing. Managed to get a logcat of the logs:

08-29 18:12:56.349 16759 16772 D         : HostConnection::get() New Host Connection established 0x8a6ab640, tid 16772
08-29 18:12:56.352 16759 16772 D EGL_emulation: eglCreateContext: 0xa5006440: maj 3 min 0 rcv 3
08-29 18:12:56.353 16759 16772 D EGL_emulation: eglMakeCurrent: 0xa5006440: ver 3 0 (tinfo 0x8a6b0610)
08-29 18:12:56.354 16759 16772 E eglCodecCommon: glUtilsParamSize: unknow param 0x00008cdf
08-29 18:12:56.354 16759 16772 E eglCodecCommon: glUtilsParamSize: unknow param 0x00008824
08-29 18:12:56.385 16759 16772 D EGL_emulation: eglCreateContext: 0xa5006560: maj 3 min 0 rcv 3
08-29 18:12:56.386 16759 16772 D EGL_emulation: eglMakeCurrent: 0xa5006560: ver 3 0 (tinfo 0x8a6b0610)
08-29 18:12:56.387 16759 16772 E eglCodecCommon: glUtilsParamSize: unknow param 0x00008cdf
08-29 18:12:56.387 16759 16772 E eglCodecCommon: glUtilsParamSize: unknow param 0x00008824
08-29 18:12:56.478  2527  2955 W Conscrypt: Could not set socket write timeout: java.lang.reflect.InvocationTargetException
08-29 18:12:56.479  2527  2955 W Conscrypt:     at java.lang.reflect.Method.invoke(Native Method)
08-29 18:12:56.479  2527  2955 W Conscrypt:     at com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@12521024@12.5.21 (040700-189987672):13)
08-29 18:12:56.479  2527  2955 W Conscrypt: Caused by: android.system.ErrnoException: setsockopt failed: EBADF (Bad file descriptor)
08-29 18:12:56.479  2527  2955 W Conscrypt:     at libcore.io.Posix.setsockoptTimeval(Native Method)
08-29 18:12:56.479  2527  2955 W Conscrypt:     at libcore.io.ForwardingOs.setsockoptTimeval(ForwardingOs.java:157)
08-29 18:12:56.510  2527  2955 W Conscrypt: Could not set socket write timeout: java.lang.reflect.InvocationTargetException
08-29 18:12:56.510  2527  2955 W Conscrypt:     at java.lang.reflect.Method.invoke(Native Method)
08-29 18:12:56.511  2527  2955 W Conscrypt:     at com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@12521024@12.5.21 (040700-189987672):13)
08-29 18:12:56.511  2527  2955 W Conscrypt: Caused by: android.system.ErrnoException: setsockopt failed: EBADF (Bad file descriptor)
08-29 18:12:56.511  2527  2955 W Conscrypt:     at libcore.io.Posix.setsockoptTimeval(Native Method)
08-29 18:12:56.511  2527  2955 W Conscrypt:     at libcore.io.ForwardingOs.setsockoptTimeval(ForwardingOs.java:157)
08-29 18:12:56.534  2527  2955 W GLSUser : [AppCertManager] IOException while requesting key:
08-29 18:12:56.534  2527  2955 W GLSUser : java.io.IOException: Invalid device key response.
08-29 18:12:56.534  2527  2955 W GLSUser :      at gga.a(:com.google.android.gms@12521024@12.5.21 (040700-189987672):12)
08-29 18:12:56.534  2527  2955 W GLSUser :      at gga.a(:com.google.android.gms@12521024@12.5.21 (040700-189987672):64)
08-29 18:12:56.534  2527  2955 W GLSUser :      at gfy.a(:com.google.android.gms@12521024@12.5.21 (040700-189987672):8)
08-29 18:12:56.534  2527  2955 W GLSUser :      at gfu.a(:com.google.android.gms@12521024@12.5.21 (040700-189987672):1)
08-29 18:12:56.534  2527  2955 W GLSUser :      at gft.a(:com.google.android.gms@12521024@12.5.21 (040700-189987672):10)
08-29 18:12:56.534  2527  2955 W GLSUser :      at com.google.android.gms.auth.account.be.legacy.AuthCronChimeraService.b(:com.google.android.gms@12521024@12.5.21 (040700-189987672):7)
08-29 18:12:56.534  2527  2955 W GLSUser :      at fiw.call(:com.google.android.gms@12521024@12.5.21 (040700-189987672):3)
08-29 18:12:56.534  2527  2955 W GLSUser :      at java.util.concurrent.FutureTask.run(FutureTask.java:237)
08-29 18:12:56.534  2527  2955 W GLSUser :      at nsg.run(:com.google.android.gms@12521024@12.5.21 (040700-189987672):27)
08-29 18:12:56.534  2527  2955 W GLSUser :      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
08-29 18:12:56.534  2527  2955 W GLSUser :      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
08-29 18:12:56.534  2527  2955 W GLSUser :      at nya.run(:com.google.android.gms@12521024@12.5.21 (040700-189987672))
08-29 18:12:56.534  2527  2955 W GLSUser :      at java.lang.Thread.run(Thread.java:761)
08-29 18:13:09.982  1941 24699 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x14008000 pkg=com.example.dbg cmp=com.example.dbg/com.example.MainActivity} from uid 10083 on display 0
08-29 18:13:10.029  1312  1333 D gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 2691072
08-29 18:13:10.126  1941  1955 W art     : Long monitor contention with owner Binder:1941_1D (24699) at int com.android.server.am.ActivityStarter.startActivityMayWait(android.app.IApplicationThread, int, java.lang.String, android.content.Intent, java.lang.String, android.service.voice.IVoiceInteractionSession, com.android.internal.app.IVoiceInteractor, android.os.IBinder, java.lang.String, int, int, android.app.ProfilerInfo, android.app.IActivityManager$WaitResult, android.content.res.Configuration, android.os.Bundle, boolean, int, android.app.IActivityContainer, com.android.server.am.TaskRecord)(ActivityStarter.java:730) waiters=1 in void com.android.server.am.ActivityManagerService$MainHandler.handleMessage(android.os.Message) for 138ms
08-29 18:13:10.130 16374 16374 D ReactNative: ReactInstanceManager.attachRootViewToInstance()
08-29 18:13:10.146 16374 16374 D onCreate: hms
08-29 18:13:10.163  1312  1332 D gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 8294400
08-29 18:13:10.297 16374 16405 D EGL_emulation: eglMakeCurrent: 0xa0aa48c0: ver 3 0 (tinfo 0xa150daa0)
08-29 18:13:10.310 16374 16405 D EGL_emulation: eglMakeCurrent: 0xa0aa48c0: ver 3 0 (tinfo 0xa150daa0)
08-29 18:13:10.354  1941  1962 I ActivityManager: Displayed com.example.dbg/com.example.MainActivity: +359ms
08-29 18:13:10.428 16374 16385 I art     : Background sticky concurrent mark sweep GC freed 46409(2MB) AllocSpace objects, 1(20KB) LOS objects, 13% free, 22MB/25MB, paused 2.106ms total 163.669ms
08-29 18:13:10.509 16374 16802 E AndroidRuntime: FATAL EXCEPTION: Firebase-RNPushNotificationListenerService
08-29 18:13:10.509 16374 16802 E AndroidRuntime: Process: com.example.dbg, PID: 16374
08-29 18:13:10.509 16374 16802 E AndroidRuntime: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this processcom.example.dbg. Make sure to call FirebaseApp.initializeApp(Context) first.
08-29 18:13:10.509 16374 16802 E AndroidRuntime:        at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@16.0.1:219)
08-29 18:13:10.509 16374 16802 E AndroidRuntime:        at com.google.firebase.messaging.MessagingAnalytics.zza(Unknown Source)
08-29 18:13:10.509 16374 16802 E AndroidRuntime:        at com.google.firebase.messaging.MessagingAnalytics.logNotificationReceived(Unknown Source)
08-29 18:13:10.509 16374 16802 E AndroidRuntime:        at com.google.firebase.messaging.FirebaseMessagingService.zzd(Unknown Source)
08-29 18:13:10.509 16374 16802 E AndroidRuntime:        at com.google.firebase.iid.zzc.run(Unknown Source)
08-29 18:13:10.509 16374 16802 E AndroidRuntime:        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
08-29 18:13:10.509 16374 16802 E AndroidRuntime:        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
08-29 18:13:10.509 16374 16802 E AndroidRuntime:        at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source)
08-29 18:13:10.509 16374 16802 E AndroidRuntime:        at java.lang.Thread.run(Thread.java:761)
08-29 18:13:10.563  1941  3715 W ActivityManager:   Force finishing activity com.example.dbg/com.example.MainActivity
08-29 18:13:10.572  1941  1962 I WindowManager: Destroying surface Surface(name=Starting com.example.dbg) called by com.android.server.wm.WindowStateAnimator.destroySurface:2016 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:882 com.android.server.wm.WindowState.removeLocked:1456 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2484 com.android.server.wm.AppWindowToken.destroySurfaces:365 com.android.server.wm.WindowStateAnimator.finishExit:565 com.android.server.wm.WindowStateAnimator.stepAnimationLocked:491 com.android.server.wm.WindowAnimator.updateWindowsLocked:303
08-29 18:13:10.628  1312  3743 D gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 2691072
08-29 18:13:10.630  1941 17568 D         : HostConnection::get() New Host Connection established 0x90e8f8c0, tid 17568
08-29 18:13:10.689  1941 17496 W art     : Long monitor contention with owner Binder:1941_16 (17568) at void com.android.server.am.ActivityManagerService.activityPaused(android.os.IBinder)(ActivityManagerService.java:6879) waiters=0 in android.content.ComponentName com.android.server.am.ActivityManagerService.startService(android.app.IApplicationThread, android.content.Intent, java.lang.String, java.lang.String, int) for 110ms
08-29 18:13:10.814  1941  1951 I art     : Background partial concurrent mark sweep GC freed 7136(488KB) AllocSpace objects, 0(0B) LOS objects, 21% free, 14MB/18MB, paused 8.864ms total 162.675ms

Key issue is this line

AndroidRuntime: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this processcom.example.dbg. Make sure to call FirebaseApp.initializeApp(Context) first.

There was no instruction on needing to initialize the FirebaseApp. How can I fix this?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:11
  • Comments:21 (1 by maintainers)

github_iconTop GitHub Comments

78reactions
prihcommented, Aug 31, 2018

for the correct work of this case - it is necessary to correctly install gms:

build.gradle

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:+'
    }
}

app/build.gradle

// EOF
apply plugin: 'com.google.gms.google-services'

after these changes everything works fine…

22reactions
xoapitcommented, Apr 7, 2019

I removed this to avoid receiving notification twice

<receiver android:name="com.google.android.gms.gcm.GcmReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="${applicationId}" /> </intent-filter> </receiver>

from AndroidManifest.xml

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native Android App crashes when receiving FCM ...
It turns out that when I get a notification, the app just stops working. The RemotePushController function seems to work, as soon as...
Read more >
App Crashes when receiving FCM Notification on Foreground ...
Coding example for the question App Crashes when receiving FCM Notification on Foreground works on Background-kotlin.
Read more >
Receive messages in an Android app - Firebase - Google
If you want foregrounded apps to receive notification messages or data messages, you'll need to write code to handle the onMessageReceived callback.
Read more >
[Solved] Android app crash when one signal notification sent
from logcat The Error <pre lang=" ; Java">2021-07-20 22 ; 10:37 ; 431 14322-16493/###### E/AndroidRuntime: FATAL EXCEPTION: Firebase-Messaging- ...
Read more >
Flutter Crash on register for Push Notifications - General
Attempting to do so crashes the app completely. ... However, I'm still getting the issue registering firebase FCM tokens - I'll look into...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found