FirebasePushNotificationPlugin icon indicating copy to clipboard operation
FirebasePushNotificationPlugin copied to clipboard

Need help > FirebasePushNotificationsPlugin : Default FirebaseApp is not initialized in this process

Open guillaumeBianchi opened this issue 5 years ago • 7 comments

Hi all,

I updated to the latest version (3.3.10) but now I get this error on Android (working on iOS):

**Java.Lang.IllegalStateException:** 'Default FirebaseApp is not initialized 
in this process com.companyname.firebasetest. 
Make sure to call FirebaseApp.initializeApp(Context) first.'

The error occurs when this FirebaseMessaging.Instance is called.

I found some solutions that does not work for me:

  • My google-services.json has the GoogleServicesJson build action (tried to put it to none again then GSJson)
  • My firebase android app package name is the same package name on my Android project.
  • I updated android's tools
  • I updated XF and so on
  • Google APIs and Play Store checked
  • Permissions allowed (internet, etc.)
  • Also tried to add this line: FirebaseApp app = FirebaseApp.InitializeApp(Android.App.Application.Context);

PS:

  • I created a new project (and new firebase project) but I get the same error
  • I pulled the sample of the FirebasePushNotification Plugin, and still getting the error
  • Notifications was working with version 2.3.x

What can I do ? I need help

Thank you guys

Bug Information

Version Number of Plugin: 3.3.10 Device Tested On: Samsung A40 Simulator Tested On: Pixel 2 Pie 9.0 API 28 Version of VS: 16.6.0 Version of Xamarin: 4.6

Steps to reproduce the Behavior

Download sample of the plugin and run it.

guillaumeBianchi avatar Jul 01 '20 15:07 guillaumeBianchi

issue when plugin version is more than 2.3.6 in VS 2019 AND xamarin.forms=4.6 and android sdk build tools is 29

Monikaprime avatar Jul 04 '20 12:07 Monikaprime

It seems that the build action for the GoogleServicesJson is not working correctly. As a workaround initialising firebase as described in this post worked for me: https://stackoverflow.com/a/51381884

ntsbs avatar Aug 11 '20 09:08 ntsbs

Same issue here. Everything's working fine on 2.3.6 but I tried to upgrade to 3.3.10 and I get the same exception (Xamarin.Forms 4.8).

ereiss01 avatar Sep 03 '20 16:09 ereiss01

Hi all, here another solution to this issue.

Regards!

mimunoz avatar Sep 03 '20 16:09 mimunoz

I have spent a few days on this issue. Tried all the solutions mentioned above. I even tried the 3.3.16-beta prerelease version. Please Help!

Saquibadil avatar Jan 31 '21 19:01 Saquibadil

I finally found a way to fix this by adding 3 packages to the android project :

  • Xamarin.GooglePlayServices.Tasks
  • Xamarin.Firebase.Messaging
  • Xamarin.Google.Dagger

I'm using 3.3.10, Xamarin.Forms 5.5, API 29.

ereiss01 avatar Mar 08 '21 11:03 ereiss01

I got it working by just cleaning the project and deleting bin/ and obj/ folders. https://github.com/CrossGeeks/FirebasePushNotificationPlugin/issues/357#issuecomment-840043331

Meekohi avatar May 12 '21 20:05 Meekohi