Linking Xamarin Forms to Firestore

Viewed 1607

I am having a issue with linking Xamarin Forms to Firestore. I have a collection called Candidates in my Firestore Database in Firebase, and I am using the Plugin.CloudFirestore nuget to link Firestore and Xamarin Forms

I have tried using the 'Get' example on the following link:

https://github.com/f-miyu/Plugin.CloudFirestore

        var query = await CrossCloudFirestore.Current
                                    .Instance
                                    .GetCollection("Candidates")
                                    .GetDocumentsAsync();


        var documents = query.ToObjects<Candidate>();

When I run the code I get the following message

"Unhandled Exception: Java.Lang.IllegalStateException: FirebaseApp with name [FirebasePlugin] doesn't exist."

Any ideas on what is going wrong?

1 Answers

Did you follow the instruction?

  • Add google-services.json to Android project. Select GoogleServicesJson as build action. (If you can't select GoogleServicesJson, reload this android project.)
  • Target Framework must be Android 9.0 (Pie). Multi-Dex needs to be enabled if you use other libraries, Xamarin.Forms etc.

    <TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
    <AndroidEnableMultiDex>true</AndroidEnableMultiDex>
    

https://github.com/f-miyu/Plugin.CloudFirestore#android

Related