【问题标题】:Firebase databasereference initialization crashes appFirebase 数据库引用初始化使应用程序崩溃
【发布时间】:2018-12-30 01:38:24
【问题描述】:

Firebase 身份验证完美运行。

项目结构是我添加谷歌服务json文件的地方

应用已连接 Firebase 数据库

每当我添加 databaseReference = FirebaseDatabase.getInstance().getReference("message"); 时,应用程序就会崩溃。我不确定我做错了什么。崩溃报告是

java.lang.NoSuchMethodError:Lcom/google/firebase/FirebaseApp 类中没有虚拟方法 zzckb()Z;或其超类('com.google.firebase.FirebaseApp' 的声明出现在 /data/app/com.example.kumarsaikat.firebaseone-hQwEzX_xqG5IhkEG8WahzQ==/base.apk) 在 com.google.firebase.database.FirebaseDatabase.getInstance(未知来源:111) 在 com.google.firebase.database.FirebaseDatabase.getInstance(未知来源:4) 在 com.example.kumarsaikat.firebaseone.ProfileActivity.onCreate(ProfileActivity.java:38) 在 android.app.Activity.performCreate(Activity.java:7091) 在 android.app.Activity.performCreate(Activity.java:7082) 在 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215) 在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2747) 在 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2872) 在 android.app.ActivityThread.-wrap11(未知来源:0) 在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1601) 在 android.os.Handler.dispatchMessage(Handler.java:106) 在 android.os.Looper.loop(Looper.java:164) 在 android.app.ActivityThread.main(ActivityThread.java:6600) 在 java.lang.reflect.Method.invoke(本机方法) 在 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:518) 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:821)

【问题讨论】:

  • 您是否尝试重新安装 firebase 依赖项?它可能是指下载它的问题。
  • 这里有一个类似的错误:stackoverflow.com/questions/44447837/…
  • 显示你的数据库层次结构
  • 请添加您的build.gradle 文件。

标签: android firebase firebase-realtime-database firebase-assistant


【解决方案1】:

好的,我自己想通了。我注意到,对于不同的配置问题,同样的错误会显示出来,因为我整天都在测试,这对我不起作用。我不是说他们错了,我是说我的问题来源不同。

这是我发现的, 在 build.gradle(app) 中的依赖

implementation 'com.google.firebase:firebase-auth:16.0.1' implementation 'com.google.firebase:firebase-core:16.0.1 implementation 'com.google.firebase:firebase-database:16.0.1''

每个版本的版本都不同。当我为所有这些都制作了相同的版本并再次同步时,该项目就可以工作了。 this reference的最后一条评论对我有帮助。

【讨论】:

    【解决方案2】:

    只需将鼠标悬停在以下三个上,然后按 (Alt+Shift+Enter) 并同步您的 Gradle,即可尝试将依赖项更新为可用的最新版本。

    实现 'com.google.firebase:firebase-auth:?????

    实现 'com.google.firebase:firebase-core:?????

    实现 'com.google.firebase:firebase-database:?????

    它对我有用:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-18
      • 1970-01-01
      • 1970-01-01
      • 2012-10-20
      • 2016-04-22
      • 2016-12-08
      • 1970-01-01
      相关资源
      最近更新 更多