Need help > FirebasePushNotificationsPlugin : Default FirebaseApp is not initialized in this process
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.
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
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
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).
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!
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.
I got it working by just cleaning the project and deleting bin/ and obj/ folders. https://github.com/CrossGeeks/FirebasePushNotificationPlugin/issues/357#issuecomment-840043331