Mike Axle
Mike Axle

Reputation: 1097

Cannot resolve FirebaseFirestore Android

I followed the official firebase android guide, but whenever I try to instantiate the FirebaseFirestore, I get a "cannot resolve symbol" error. The issue is as shown below: enter image description here

Before this is marked as a duplicate, I have been searching for a solution to this issue for hours now. Nothing I found online works. Below is my gradle config: app:

enter image description here

root: enter image description here

Is there any idea what I am doing wrong? I have tried various different plugin versions for fireStore and firebase app but nothing seems to work

Upvotes: 7

Views: 5105

Answers (9)

dependencies {
// Import the BoM for the Firebase platform
implementation(platform("com.google.firebase:firebase-bom:33.0.0"))

// Declare the dependency for the Cloud Firestore library
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation("com.google.firebase:firebase-firestore")

}

Upvotes: 0

Sanchoyeeta Sarkar
Sanchoyeeta Sarkar

Reputation: 36

I recently faced this problem. There is a simple solution.

  1. Add this to your app Gradle:
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.firebaseui:firebase-ui-firestore:4.3.1'
  1. Import the following statement:
import com.google.firebase.firestore.FirebaseFirestore;

Thank me later :)

Upvotes: 0

kelvinO
kelvinO

Reputation: 11

Try adding this to your gradle

The FirestoreRecyclerAdapter class is part of the FirebaseUI Library but not the core Firestore SDK

implementation 'com.firebaseui:firebase-ui-firestore:4.3.1'

Upvotes: 1

Bhriguraj Salponia
Bhriguraj Salponia

Reputation: 126

project build.gradle

allprojects {
   repositories {
      google()
      jcenter()
      maven { url 'https://jitpack.io' }
}}

Upvotes: 0

I Recently Had that Error and this are the steps that I tried, I am not pretty sure which one of these did the trick but the error was solved and I was able to utilize fireStore. These are not in any Order I just randomly continued doing these.

I hope these helps. Check for these

1. Have You Installed Google Play Services and Google Repository.

Check for the Updated Version and install it if available.

2. Try to Match All the Versions in the gradle config: app ... for eg,

     implementation 'com.google.firebase:firebase-core:16.0.3'
     implementation 'com.google.firebase:firebase-firestore:16.0.3'

Sync Those Files for Quite few times

3. Clear Caches and Restart the Android Studio IDE

Step 1:- Go to File Menu > Invalidate Caches/Restart..
Step 2:- Click on Invalidate and Restart on the Window that Appears

This will restart the project and rebuild it, Stay calm as this can take quite a time.


After Following These Steps all my Error were Solved and I was able to instantiate the FirebaseFirestore.

Upvotes: 0

Raj
Raj

Reputation: 3001

Try this:-

  1. In Android Studio, click on File.
  2. Then click Sync Project with Gradle Files.

Upvotes: 0

Krishna Sharma
Krishna Sharma

Reputation: 2877

Looks like you have missed import statement

import com.google.firebase.firestore.FirebaseFirestore;

enter image description here

Upvotes: 0

Odai A. Ali
Odai A. Ali

Reputation: 1215

Try close your project and reimport it again

Upvotes: 0

Martin Zeitler
Martin Zeitler

Reputation: 76669

it all hints for, that the artifact had not yet been downloaded...

check if Gradle isn't in offline mode; and sync or build the project once.

alternatively, run ./gradlew clean assembleDebug from a terminal.

repository mavenCentral() is also rather relevant than mavenLocal().

while the repository for these artifacts should be the google() one.

another known issue is, that one may have to prefer IPv4, in the gradle.properties file:

org.gradle.jvmargs=-Djava.net.preferIPv4Stack=true

Upvotes: 1

Related Questions