gpt4 book ai didi

Firebase 数据库 getInstance 导致应用程序崩溃

转载 作者:行者123 更新时间:2023-12-02 21:53:43 26 4
gpt4 key购买 nike

创建 google-service.json 后运行示例时,应用在尝试在 SignInActivity 中获取数据库引用时崩溃

mDatabase = FirebaseDatabase.getInstance().getReference();

崩溃日志

05-21 09:27:27.644 488-488/com.google.firebase.quickstart.database D/AndroidRuntime: Shutting down VM
05-21 09:27:27.644 488-488/com.google.firebase.quickstart.database E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.google.firebase.quickstart.database, PID: 488
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.firebase.quickstart.database/com.google.firebase.quickstart.database.SignInActivity}: com.google.firebase.database.DatabaseException: Failed to get

FirebaseDatabase instance: FirebaseApp object has no DatabaseURL in its FirebaseOptions object.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: com.google.firebase.database.DatabaseException: Failed to get FirebaseDatabase instance: FirebaseApp object has no DatabaseURL in its FirebaseOptions object.
at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
at com.google.firebase.quickstart.database.SignInActivity.onCreate(SignInActivity.java:39)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

如何解决这个问题?

最佳答案

Firebase console 中的项目设置下载 google-services.json 。我的错误是从https://developers.google.com/mobile/add下载它.

关于Firebase 数据库 getInstance 导致应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37363791/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com