1

I have a Xamarin Forms Solution in Visual Studio 2019. I am working with just the Android version for now. The full error is:

Java.Lang.IllegalStateException Message=Default FirebaseApp is not initialized in this process appcardview.sample.android. Make sure to call FirebaseApp.initializeApp(Context) first.

In my Android project, I am trying to connect to Firebase Authentication. I have added my google-services.json. I have seen online that it should be added as:

<ItemGroup>
    <GoogleServicesJson Include="google-services.json" />
</ItemGroup>

But that gives me an error telling me that GoogleServicesJson is unrecognized, so I added it in my .csproj file as

  <ItemGroup>
    <None Include="google-services.json" />
    <None Include="Resources\AboutResources.txt" />
    <None Include="Assets\AboutAssets.txt" />
    <None Include="Properties\AndroidManifest.xml" />
  </ItemGroup>

1-I have also added the following line in the beginning fo the onCreate method in my MainActivity class in the android project; I have added it to the beginning of my onCreate, maybe I need to place it somewhere else?:

FirebaseApp.InitializeApp(Application.Context);

2-Can the problem be the way I added it in my .csproj file?

3-Someone also mentioned the following and I am not sure what it means or what I should change, maybe this is the problem?

Make sure that your package name is identical to the package name inside “google-services.json”

halfer
  • 19,824
  • 17
  • 99
  • 186
ndrb
  • 91
  • 2
  • 8

1 Answers1

1

I finally figured it out, I just had to follow the steps here:

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

Side note: for step 2, this other article explains how to do it:

https://forums.xamarin.com/discussion/175159/i-didnt-find-googleservices-json-in-the-build-action

ndrb
  • 91
  • 2
  • 8