cordova-plugin-firebase: Default FirebaseApp is not initialized
After updating to plugin version 1.1.0, app crashes immediately at launch on Android devices.
Log excerpt:
09-01 13:01:12.929 25125-25125/com.xxx.xxx E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xxx.xxx, PID: 25125
java.lang.ExceptionInInitializerError
at com.google.android.gms.internal.firebase-perf.zzw.zzae(Unknown Source)
at com.google.firebase.perf.metrics.Trace.start(Unknown Source)
at com.google.android.gms.internal.firebase-perf.zze.onActivityStarted(Unknown Source)
at android.app.Application.dispatchActivityStarted(Application.java:207)
at android.app.Activity.onStart(Activity.java:1191)
at org.apache.cordova.CordovaActivity.onStart(CordovaActivity.java:297)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1249)
at android.app.Activity.performStart(Activity.java:6701)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2751)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1496)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6186)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.xxx.xxx. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@16.0.1:219)
at com.google.android.gms.internal.firebase-perf.zzw.<init>(Unknown Source)
at com.google.android.gms.internal.firebase-perf.zzw.<clinit>(Unknown Source)
I realize this may be a duplicate of #142, #715 or #206 but those are closed and meant to be fixed.
We have been using the plugin for quite a while and never actually encountered this before. It’s only occurring in plugin version 1.1.0 for us. We have downgraded to version 1.0.5 again and now everything works again. So, I thought I’d open a new issue for this as there may be some regression error. Happy to provide more info if there are questions…
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 37 (11 by maintainers)
Commits related to this issue
- Merge pull request #820 from Drintios/fixSource #816 Fix for google services issue (Firebase not initialized) — committed to arnesson/cordova-plugin-firebase by soumak77 6 years ago
@CWollinger thanks! adding window.FirebasePlugin.initFirebase() worked for me too. i am using version 1.1.2
Adding window.FirebasePlugin.initFirebase(); before getToken worked for me.
On iOS I was getting the error “Firebase isn’t initialised” when calling the getToken method. I also managed to get things working by downgrading to v1.0.5 (which my Android version was already running and was working fine with, as far as I could tell).
Thanks @BrainOverflown , I’ll follow your thread!
I already did @Drintios
@BrainOverflown @rubytann I am using iOS so Android would look slightly different, but here is my getToken() function that is working 100% on emulator and device. The code is in a provider that is called on the ionViewDidEnter() lifestyle hook on the root page.
async getToken() { (<any>window).FirebasePlugin.initFirebase() let token; if (this.platform.is('ios')) { token = await this.fireNative.getToken(); const perm = await this.fireNative.grantPermission() } return this.saveToken(token) }
@8tomo8 I have the same question. I added
(<any>window).FirebasePlugin.initFirebase()
in app.components.ts, my app just froze. I’m using ionic 3 too. Could you please explain where I should use it?