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@[email protected] (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@[email protected] (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@[email protected] (040700-189987672):12)
08-29 18:12:56.534 2527 2955 W GLSUser : at gga.a(:com.google.android.gms@[email protected] (040700-189987672):64)
08-29 18:12:56.534 2527 2955 W GLSUser : at gfy.a(:com.google.android.gms@[email protected] (040700-189987672):8)
08-29 18:12:56.534 2527 2955 W GLSUser : at gfu.a(:com.google.android.gms@[email protected] (040700-189987672):1)
08-29 18:12:56.534 2527 2955 W GLSUser : at gft.a(:com.google.android.gms@[email protected] (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@[email protected] (040700-189987672):7)
08-29 18:12:56.534 2527 2955 W GLSUser : at fiw.call(:com.google.android.gms@[email protected] (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@[email protected] (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@[email protected] (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?
Same issue
same
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...
It works fine for me, thanks #prih
Wow, it is working for me. Thank you so much @prih
I find myself with this error someone can help me :
Android dependency 'com.google.firebase:firebase-iid' has different version for the compile (16.0.0) and runtime (17.0.1) classpath. You should manually set the same version via DependencyResolution
Do we need to install firebase into the app also for this to work?
I added any installation @prih in build.gradle and app/build.gradle but the app crash again.
help me
Someone could send me his code that I can see my errors pls
my mistake when I receive the notification:
Process: com.vetotrack, PID: 27552
java.lang.ClassCastException: com.google.firebase.iid.zzf cannot be cast to com.google.android.gms.iid.zzi
at com.google.android.gms.iid.zzk.onServiceConnected(Unknown Source:4)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1634)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1663)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
This works:
https://github.com/zo0r/react-native-push-notification/issues/796#issuecomment-410801969
My problem was using FCM, (I setup for GCM, and my manifest was wrong).
Any news on this issue, my app is still crashing when receiving a FCM notification. I'm using only the FCM config.
@StijnCoolen Did you find the solution?
I tried the steps in this thread as well as #796 recommendations.
@bernhardt1 I completely switched to react-native-firebase.
@prih
After applying your fix I now have the problem of receiving every push notification twice. Has anyone experienced this?
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
i was able to fix this issue by updating my dependencies like this:
diff --git a/android/build.gradle b/android/build.gradle
index f6291a49..027272ce 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -14,7 +14,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
- classpath 'com.google.gms:google-services:4.1.0'
+ classpath 'com.google.gms:google-services:4.2.0'
}
}
Prih's answer worked for me.
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
Hello, i remove your said lines. Notification showing if app is running background but if app is running on screen not firing onNotification function or notification is showing in status bar..
@prih
After applying your fix I now have the problem of receiving every push notification twice. Has anyone experienced this?
use only FCM, forget about GCM...
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
Worked for me, and notification is appearing fine
Most helpful comment
for the correct work of this case - it is necessary to correctly install gms:
build.gradle
app/build.gradle
after these changes everything works fine...