Hello! I'm trying to add push notifications in Xamarin.Forms.
On Genymotion it's work fine but on real devices i have an error:
Default FirebaseApp is not initialized.Make shure to call FirebaseApp.initializeApp(Context)
google-services.json is present in Android project with GoogleServicesJson BuildAction
My MainActivity:
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity { internal static MainActivity Instance { get; private set; } internal static FirebaseInstanceId FirebaseInstance { get; private set; } public static int CurrentUserId { get; set; } protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; VideoViewRenderer.Init(); global::Xamarin.Forms.Forms.Init(this, bundle); string dbPath = FileAccessHelper.GetLocalFilePath("LocalDataBase.db"); LoadApplication(new App()); Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize); UserDialogs.Init(this); CachedImageRenderer.Init(); //on real devices it return null var app = Firebase.FirebaseApp.InitializeApp(this.ApplicationContext); Instance = this; }
Posts
Do i need to create Application class that extends Application and call Firebase.FirebaseApp.InitializeApp(this.ApplicationContext) in that class?
Worked after downgrade NuGet Xamari.Firebase.Messaging to 42.1001.0
Hey,
I had the same problem and after some investigation I've tried to initiate it manually in that way
That worked for me and it seems that the build process "GoogleServiceJson" doesn't work which should does it instead.
Best regards,
Thomas
In my case the Firebase app not initialized until I cleaned the solution and re-ran then all worked fine (VS2017, Firebase v60).
Google-services.json was pulled in fine (without using the options builder as above) and I had no need to call FirebaseApp.InitializeApp manually (apparently this is done automatically whenever registration is required).
In my case I had the package name different between my application and my firebase project. So I created another project with the correct package name and downloaded the google-services.json again and put into my application.
In my case adding "using Firebase;" to the MainActivity works for me
I have the same issue, Rebuild my project solved the issue.
Add this Nuget package in the Android project:
Xamarin.GooglePlayServices.Basement
. After that package has been installed, you will be able to choose the GoogleServicesJson in the build action.work for me.
at any moment, he no longer compiled the google-services file
I had the same issue, somehow I had to manually add Xamarin.Firebase.Messaging. to my Nuget packages. The plugin has a dependency but did not properly download it.
After two days of troubleshooting, finally i found out that the latest versions of the below nuget packages (or may be one of them) is causing this. I downgraded to the below versions and it started working.