Xamarin.android By default, FirebaseApp is not initialized in this process

I am facing a problem with getting a token from firebase (push notification)

Default FirebaseApp is not initialized in this process com.ready_apps.Nebka.Business. Make sure to call FirebaseApp.initializeApp(Context) first. 

even I called FirebaseApp.InitializeApp (this); in many places

MyApplication (application extension) in onCreate of Activity, where I call FirebaseInstanceId.Instance?.Token;

+7
android push-notification xamarin.android firebase firebase-cloud-messaging
source share
3 answers

Edit: This error was fixed in Xamarin.Firebase version 57.1104.0-beta1.

This error seems to be present in newer versions of Firebase for Xamarin. I also experience this error today, using the latest stable version 42.1021.1. (An error is also present in the latest beta).

I found that an error report was sent for the problem.

As mentioned in the bug report, deleting the / obj and / bin folders in your Android project and / or cleaning up the project in Visual Studio should temporarily fix the problem until you update any resource that changes Resource.Designer.cs.

Switching to an earlier version of Firebase and Google Play services is also possible before a permanent solution is available. For example, I did not experience this error in Firebase and Google Play Services version 32.961.0.

+10
source share

Just clear the solution and run the application again.

This error has already been reported by Xamarin. https://bugzilla.xamarin.com/show_bug.cgi?id=56108

This solution is provided in its comment stream; it can be fixed in the new version of the xamarin NuGet package.

+3
source share

I did not fix it, but found that this problem is only in debug mode

I called this onCreate () method in activit I need to request a token

 FirebaseInstanceId.Instance?.Token 

here is the method

 private void ConfigureFireBase() { #if DEBUG try { Task.Run(() => { var instanceId = FirebaseInstanceId.Instance; instanceId?.DeleteInstanceId(); //Log.Debug("TAG", "{0} {1}", instanceId?.Token?.ToString(), instanceId.GetToken(GetString(Resource.String.gcm_defaultSenderId), Firebase.Messaging.FirebaseMessaging.InstanceIdScope)); }); // For debug mode only - will accept the HTTPS certificate of Test/Dev server, as the HTTPS certificate is invalid /not trusted ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true; }catch (Exception e) { Log.Debug("TAG", e.Message); } #endif } 
0
source share

All Articles