Canot Resolve symbol 'GeoFirestore'

318 Views Asked by At

I am creating a Map based app on Android Platform . I am using Firebase Firestore as backend Database in this project. I wanted to add GeoFire in my Firestore database . I have added following dependencies in my gradle file to add Firestore and GeoFire in my project:

implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-firestore:17.1.2'
implementation 'com.firebase:geofire-android:2.3.1'

but after sucessfull gradle sync when i add

CollectionReference geoFirestoreRef = FirebaseFirestore.getInstance().collection("my-collection");
GeoFirestore geoFirestore = new GeoFirestore(geoFirestoreRef);

It gives Error 'Unable to resolve GeoFirestore'

I dont understand why this error appears although i have added all the required dependencies in my gradle file . Attached picture also. enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

The problem in your code is that you are trying to use GeoFirestore library for Android but you are using a dependency for GeoFire for Android, which is a total different product. GeoFirestore works with Cloud Firestore while GeoFire works with Firebase realtime database.

This is also the reason why you are getting the following error:

Unable to resolve GeoFirestore

Because you are trying to create an object of GeoFirestore class which is a class that was not imported. In order to solve this issue, you need to add in your build.gradle file the corresponding GeoFirestore dependency:

implementation 'com.github.imperiumlabs:GeoFirestore-Android:v1.1.1'

And in your build.gradle (project) file:

allprojects {
    repositories {
        //...
        maven { url 'https://jitpack.io' }
    }
}

Here you can find more informations.