【问题标题】:NoSuchMethodError with FirebaseDatabase.getInstance() [duplicate]带有 FirebaseDatabase.getInstance() 的 NoSuchMethodError [重复]
【发布时间】:2018-08-23 16:01:56
【问题描述】:

当我尝试在 Firebase 数据库中保存数据时,我的应用崩溃了。错误显示在这一行:

databaseUser = FirebaseDatabase.getInstance().getReference("Users");

堆栈跟踪:

08-24 00:24:16.275 11091-11091/com.addaj.mobilerecommendationsystem E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.addaj.mobilerecommendationsystem, PID: 11091
    java.lang.NoSuchMethodError: No virtual method zzbqo()Z in class Lcom/google/firebase/FirebaseApp; or its super classes (declaration of 'com.google.firebase.FirebaseApp' appears in /data/app/com.addaj.mobilerecommendationsystem-1/split_lib_dependencies_apk.apk)
        at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
        at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
        at com.addaj.mobilerecommendationsystem.RegistrationActivity.onCreate(RegistrationActivity.java:60)
        at android.app.Activity.performCreate(Activity.java:6860)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2674)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2782)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1521)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:163)
        at android.app.ActivityThread.main(ActivityThread.java:6228)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)

【问题讨论】:

  • 您必须提供更多信息以尽可能详细地说明您的问题,以便更容易找到问题!
  • 错误是什么?
  • 我应该提供什么信息?你能指导我 Joe S 吗?
  • 我的应用因为 getInstance() 而崩溃
  • 你能显示完整的代码吗?

标签: java android


【解决方案1】:

你必须使 firebase 库版本相同:

implementation 'com.google.firebase:firebase-storage:11.8.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'

或选择您想要的任何版本,例如 16.0.1 查看 firebase 发行说明:Firebase Release Notes

【讨论】:

  • 它的工作先生!我只需要更改我的数据库版本。谢谢!
  • 哦,那太好了 :) 我很高兴它起作用了...随时投票
猜你喜欢
  • 1970-01-01
  • 2016-09-21
  • 2021-09-08
  • 2019-07-22
  • 2013-12-30
  • 2012-08-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多