无法启动活动ComponentInfo。 java.lang.NullPointerException:Firestore组件不存在

问题描述 投票:1回答:1

我在Android上使用Firebase,我试图通过以下方式实例化Firestore:FirebaseFirestore rootRef = FirebaseFirestore.getInstance()但是我得到Null指针异常

p.s。:如果我没有实例化FirebaseApp FirebaseApp.initializeApp(this)), I get the error: "java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process. Make sure to call FirebaseApp.initializeApp(Context) first.

[EDITED]

APP build.gradle:

https://pastebin.com/k7e0Vzy4

PROJECT build.gradle:

https://pastebin.com/hMjwpAK9

有什么建议?

android firebase google-cloud-firestore
1个回答
0
投票

在获取实例之前使用Firebase初始化应用程序

FirebaseApp.initializeApp(this);
FirebaseFirestore rootRef = FirebaseFirestore.getInstance()
© www.soinside.com 2019 - 2024. All rights reserved.