8
Java.Lang.IllegalStateException: Default FirebaseApp is not initialized in this process TestChartApp.TestChartApp. Make sure to call FirebaseApp.initializeApp(Context) first.

this is my code i am using

FirebaseApp.InitializeApp(this);

try
    {
        throw new NotImplementedException();
    }
    catch (System.Exception ex)
    {   
    FirebaseCrash.Report(ex);
    }

I am new to implement firebase crash reporting i am trying to implement crash report but it is throwing an error. please help me how can i solve that.

Srinivas Ch
  • 1,202
  • 2
  • 19
  • 34
  • 2
    Review the logcat output and make sure you are not getting: **`[FirebaseInitProvider] FirebaseApp initialization unsuccessful`** If so, make sure that your `google-services.json` is assigned the build action of `GoogleServicesJson` and that your application package id matches the one that you assigned in the Google Dev. Console – SushiHangover Feb 10 '17 at 11:47
  • try using your application context, it also gives you lesser chance on leaking your activity – DennisVA Feb 10 '17 at 12:04
  • @SrinivasCh Glad to help, I created an answer from my comment – SushiHangover Feb 10 '17 at 12:30

4 Answers4

27

Review your logcat output for FirebaseInitProvider tags, if you are getting:

[FirebaseInitProvider] FirebaseApp initialization unsuccessful

Then the two major things to check:

  • Make sure that your google-services.json is assigned a build action of GoogleServicesJson

  • Check that your application package name matches the one that you assigned in the Google Dev. Console

A successful FirebaseApp registration will result in the following logcat:

FirebaseInitProvider: FirebaseApp initialization successful

SushiHangover
  • 73,120
  • 10
  • 106
  • 165
4

After assigned the build action as GoogleServicesJson its working.

Srinivas Ch
  • 1,202
  • 2
  • 19
  • 34
3

Try entering the following in MainActivity.cs after the LoadApplication call.

FirebaseApp app = FirebaseApp.InitializeApp(Android.App.Application.Context);
Novjean
  • 51
  • 1
  • 5
3

The resolution for me was toggling the BuildAction for the google-services.json to GoogleServicesJson.

Even though the google-services.json properties showed BuildAction set to GoogleServicesJson, I was still having the error "Default FirebaseApp is not initialized in this process Make sure to call FirebaseApp.initializeApp(Context) first".

I was able to resolve this issue by setting BuildAction to "None" then setting it back to "GoogleServicesJson". When I got latest version from source control the BuildAction must not have carried over to my local copy (although it showed as such).

mdlars
  • 909
  • 10
  • 16