I am unable to obtain an instance of Firebase Firestore on Android.This line of code below fails repeatedly.
FirebaseFirestore db = FirebaseFirestore.getInstance();
It throws java.lang.IllegalArgumentException
with the error
FirebaseOptions.getProjectId() cannot be null
Caused by: java.lang.IllegalArgumentException: FirebaseOptions.getProjectId() cannot be null
at com.google.firebase.firestore.FirebaseFirestore.zze(Unknown Source)
at com.google.firebase.firestore.FirebaseFirestore.getInstance(Unknown Source)
I have enabled Firestore on the console, I have used Firebase Assistant to ensure Android Studio project is synched up correctly with the console project. Other Firebase components that I am using such as Real-time Database, Authentication, Storage, etc works except Firestore.
I have added the dependency compile 'com.google.firebase:firebase-firestore:11.4.2'
What am I missing?
Copy project_id from google-services.json to string.xml then it works fine.
dependencies {
The project ID is read from the
google-services.json
file.Make sure you have a recent
google-services.json
file and are usingcom.google.gms:google-services:3.1.0
or higher (not3.0.0
).Try updating your
implementation 'com.google.firebase:firebase-firestore:17.0.2'
That's that latest currently. Please check your firebase console for the most recent version