Firebase Firestore GetInstance在Android上失败 [英] Firebase Firestore GetInstance Failing on Android

查看:34
本文介绍了Firebase Firestore GetInstance在Android上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在Android上获取Firebase Firestore的实例.下面的这一行代码反复失败.

I am unable to obtain an instance of Firebase Firestore on Android.This line of code below fails repeatedly.

FirebaseFirestore db = FirebaseFirestore.getInstance();

它抛出 java.lang.IllegalArgumentException 错误

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)

我已在控制台上启用Firestore,我已使用Firebase Assistant来确保Android Studio项目与控制台项目正确同步.除了Firestore,我正在使用的其他Firebase组件(例如实时数据库,身份验证,存储等)都可以使用.

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.

我已经添加了依赖项 compile'c​​om.google.firebase:firebase-firestore:11.4.2'

我想念什么?

推荐答案

google-services.json 文件中读取项目ID.

The project ID is read from the google-services.json file.

确保您具有最新的 google-services.json 文件,并且使用的是 com.google.gms:google-services:3.1.0 或更高版本(不是<代码> 3.0.0 ).

Make sure you have a recent google-services.json file and are using com.google.gms:google-services:3.1.0 or higher (not 3.0.0).

这篇关于Firebase Firestore GetInstance在Android上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆