当我尝试将数据保存在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)
答案 0 :(得分: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