Saikat halder
Saikat halder

Reputation: 618

Firebase databasereference initialization crashes app

Firebase authentication works perfectly.

The project Structure is this where I added google service json file

The project Structure is this where I added google service json file.

The app is connected with Firebase database

Firebase database.

Whenever I just add databaseReference = FirebaseDatabase.getInstance().getReference("message"); , The app crashes. I am not sure what I have done wrong. The crash report is

java.lang.NoSuchMethodError: No virtual method zzckb()Z in class Lcom/google/firebase/FirebaseApp; or its super classes (declaration of 'com.google.firebase.FirebaseApp' appears in /data/app/com.example.kumarsaikat.firebaseone-hQwEzX_xqG5IhkEG8WahzQ==/base.apk) at 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) at android.app.Activity.performCreate(Activity.java:7082) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215) at 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) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at 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)

Upvotes: 1

Views: 2562

Answers (2)

vishnukumar
vishnukumar

Reputation: 1

Try updating the dependencies to the latest version available by just hovering your mouse on the following three and press(Alt+Shift+Enter) and Sync your Gradle.

implementation 'com.google.firebase:firebase-auth:?????

implementation 'com.google.firebase:firebase-core:?????

implementation 'com.google.firebase:firebase-database:?????

It worked for me :)

Upvotes: 0

Saikat halder
Saikat halder

Reputation: 618

Ok, I have figured it out by myself. What I noticed is that the same error can show for different configuration problems, as I have tested all throughout my day, which did not work for me. I am not saying they are wrong, I am saying my problem source was different.

Here what I found, in the build.gradle(app) in the dependencie

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''

The versions were different for each of them. When I made the same version for all of them and synced again, the project work. The last comment of this reference helped me.

Upvotes: 1

Related Questions