Notification plugin crash

Hello,

I’m trying to make a new app using capacitor, and i get a crash when trying to use notification plugins.

I followed the guideline here.

Running PushNotifications.register() makes app crash, and i get this error message in Android studio console:

Default FirebaseApp is not initialized in this process my.pack.name . Make sure to call FirebaseApp.initializeApp(Context) first.

Here is my config:

Ionic:

Ionic CLI : 6.6.0 (/home/florent/.nvm/versions/node/v12.14.0/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.0.7
@angular-devkit/build-angular : 0.803.26
@angular-devkit/schematics : 8.3.26
@angular/cli : 8.3.26
@ionic/angular-toolkit : 2.2.0

Capacitor:

Capacitor CLI : 2.0.2
@capacitor/core : 2.0.2

Utility:

cordova-res (update available: 0.13.1) : 0.12.1
native-run : 1.0.0

System:

NodeJS : v12.14.0 (/home/florent/.nvm/versions/node/v12.14.0/bin/node)
npm : 6.13.4
OS : Linux 4.15

I would appreciate a lot any help on understanding what’s happening here !

Ok I found my mistake, the google-service.json was just not in the right directory android/app.

1 Like

Hi

I am getting the same error message. I have placed the goggle-sevice.json file in android/app as well. But still getting the same crash.

Do i simple do a sync or build in capacitor before Anrdroid studio. How to make sure goggle-sevice.json is being passed into Andriod Studio.

Hi,

Were you able to solve the issue? I’m facing the same issue, and my Google-services.JSON file is in the correct directory.

The error is thrown while calling the .register() method. And the error is only on the Android platform.

Thank you!

i proposed a fix

The issue was fixed after I migrated to Capacitor v3 - the older plug-in was using a deprecated method.

How to migrate to v3 can you help me out ?

You can check the documentation here: Capacitor - build cross platform apps with the web

It depends on whether the community plugins you currently use support Capacitor v3 or not, so you would have to check that for every individual plugin.

All the official plugins support Capacitor v3 though.

Let me know how it goes :slight_smile:

Copy the google-servives.json file to android/app and try again.