3 月,1 周
Questions & Answers
84
Caused by: com.google.firebase.database.DatabaseException: Failed to get FirebaseDatabase instance: Specify DatabaseURL within FirebaseApp or from your getInstance() call.
at com.google.firebase.database.FirebaseDatabase.getInstance(com.google.firebase:firebase-database@@16.0.5:114)
at com.google.firebase.database.FirebaseDatabase.getInstance(com.google.firebase:firebase-database@@16.0.5:71)
at pl.cyfrogen.budget.FirebaseHandler.onCreate(FirebaseHandler.java:11)
at 安卓.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1190)
at 安卓.app.ActivityThread.handleMakeApplication(ActivityThread.java:7184)
at 安卓.app.ActivityThread.handleBindApplication(ActivityThread.java:7134)
at 安卓.app.ActivityThread.access$1500(ActivityThread.java:274)
at 安卓.app.ActivityThread$H.handleMessage(ActivityThread.java:2102)
at 安卓.os.Handler.dispatchMessage(Handler.java:107)
at 安卓.os.Looper.loop(Looper.java:237)
at 安卓.app.ActivityThread.main(ActivityThread.java:8167)
at java.lang.reflect.Method.invoke(Native Method)
at com.安卓.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.安卓.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
import 安卓.app.Application;
import com.google.firebase.database.FirebaseDatabase;
public class FirebaseHandler extends Application {
@Override
public void onCreate() {
super.onCreate();
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
}
}
# 1 楼答案
根据文档,
FirebaseDatabase.getInstance()
可以接受URL作为字符串。我希望您需要在这里添加您的项目URL,例如Check out the documentation here