Reputation: 93
I'm trying to use Firebase for a simple CRUD android app, but while instantiation of a Firebase database reference, I encounter the following exception at runtime:
java.lang.RuntimeException: Uncaught exception in Firebase Database runloop (3.0.0). Please report to [email protected]
at com.google.firebase.database.android.AndroidPlatform$1$1.run(com.google.firebase:firebase-database@@16.1.0:98)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
....
....
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/FirebaseApp$IdTokenListener;
....
....
at com.satwick.employeecrud.MainActivity.onCreate(MainActivity.java:76)
I went through StackOverflow, and although there have been many cases of NoClassDefFoundError in Firebase, none of them were about IdTokenListener
. What I mainly realized is this might've been an error of missing some steps, while setting up the Firebase database. So I rechecked all steps:
In the onCreate() method:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initialize Firebase Auth
mFirebaseAuth = FirebaseAuth.getInstance();
mFirebaseUser = mFirebaseAuth.getCurrentUser();
if (mFirebaseUser == null) {
List<AuthUI.IdpConfig> providers = Arrays.asList(new AuthUI.IdpConfig.PhoneBuilder().build());
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers)
.build(),
RC_SIGN_IN);
} else {
mUsername = mFirebaseUser.getDisplayName();
}
// MainActivity.java:76 The following line causes the exception.
mFirebaseDatabaseReference = FirebaseDatabase.getInstance().getReference();
}
Is this a bug with Firebase? Or am I doing something wrong? Please help.
Also, I don't know if this is related or not, but I have two applications registered with the same Firebase project, with the same signing key (Android Studio's default SHA1.)
EDIT 1 - Adding dependencies {} of build.gradle:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0-alpha07'
// Google
implementation 'com.google.android.gms:play-services-auth:16.0.1'
// Firebase
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation platform('com.google.firebase:firebase-bom:17.0.0')
implementation 'com.google.firebase:firebase-database'
implementation 'com.google.firebase:firebase-storage'
implementation 'com.google.firebase:firebase-auth:17.0.0'
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
// Firebase UI
implementation 'com.firebaseui:firebase-ui-database:3.3.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Upvotes: 2
Views: 7667
Reputation: 304
I tried downgrading my version from
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
to
implementation 'com.firebaseui:firebase-ui-auth:4.3.0'
and
implementation 'com.google.firebase:firebase-database:19.2.0'
to
implementation 'com.google.firebase:firebase-database:16.0.4'
and it worked
Upvotes: -1
Reputation: 93
I was using some unwanted libraries in build.gradle
, so cleared off the clutter to the following imports for Firebase:
// Firebase
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-auth:17.0.0'
// Firebase UI
implementation 'com.firebaseui:firebase-ui-auth:5.0.0'
implementation 'com.firebaseui:firebase-ui-database:5.0.0'
Consequently, I tried updating the version of firebase-ui from 4.3.1 -> 5.0.0, and it worked.
Upvotes: 6