繁体   English   中英

Firebase 数据库引用初始化使应用程序崩溃

[英]Firebase databasereference initialization crashes app

Firebase 身份验证工作完美。

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

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

该应用已与 Firebase 数据库连接

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(Unknown Source:111) at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source:4) at com.example.kumarsaikat.firebaseone.ProfileActivity.onCreate(ProfileActivity.java:38) at 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) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2872) at android.app.ActivityThread.-wrap11(Unknown Source:0) at 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) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:518) at com。 android.internal.os.ZygoteInit.main(ZygoteInit.java:821)

好的,我已经自己弄清楚了。 我注意到的是,对于不同的配置问题,可能会显示相同的错误,因为我一整天都在测试,这对我不起作用。 我不是说他们错了,我是说我的问题来源不同。

这是我发现的,在依赖项的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''

他们每个人的版本都不同。 当我为所有这些制作相同的版本并再次同步时,项目就成功了。 这个参考的最后一条评论对我有帮助。

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

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

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

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

它对我有用:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM