Why when i´m trying to write in Firebase Database I got this error? Related with FirebaseApp$IdTokenListener

安稳与你 提交于 2020-07-07 11:15:47

问题


I'm just trying to write a message in database, then I have this error when I run the app

As I know I already added necesary dependencies in my gradle

gradle at module level, I already added Firebase Core, Firebase database and so on:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
    implementation 'com.android.support:design:28.0.0-rc02'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-vector-drawable:28.0.0-rc02'
    implementation 'com.android.support:support-v4:28.0.0-rc02'

    implementation 'com.firebaseui:firebase-ui-auth:5.0.0'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.2.1'

    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    implementation 'com.google.firebase:firebase-core:16.0.8'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'de.hdodenhof:circleimageview:3.0.0'

    implementation 'com.github.bumptech.glide:glide:4.9.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
    implementation 'com.facebook.android:facebook-android-sdk:[4,5)'

    implementation 'com.facebook.android:facebook-android-sdk:4.42.0'

    implementation 'com.android.support:multidex:1.0.3'
}
apply plugin: 'com.google.gms.google-services'

gradle at project level

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.google.gms:google-services:4.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

And finally code when I have the issue:

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

/*In this line i got the error in Logcat -> */FirebaseDatabase database = FirebaseDatabase.getInstance();
        DatabaseReference myReference = database.getReference("message");
        myReference.setValue("Hello, world!");
}

This is the error that I got when i run the app

E/RunLoop: Uncaught exception in Firebase Database runloop (3.0.0). Please report to firebase-database-client@google.com
    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/FirebaseApp$IdTokenListener;
        at com.google.android.gms.internal.firebase_database.zzq.zza(Unknown Source:0)
        at com.google.android.gms.internal.firebase_database.zzbz.zzba(Unknown Source:119)
        at com.google.android.gms.internal.firebase_database.zzdo.zzb(Unknown Source:0)
        at com.google.android.gms.internal.firebase_database.zzdo.zza(Unknown Source:2)
        at com.google.firebase.database.FirebaseDatabase.zzc(Unknown Source:9)
        at com.google.firebase.database.FirebaseDatabase.getReference(Unknown Source:0)
        at com.antonio.yomassegura.Activities.MainActivity.onCreate(MainActivity.java:97)
        at android.app.Activity.performCreate(Activity.java:7009)
        at android.app.Activity.performCreate(Activity.java:7000)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.FirebaseApp$IdTokenListener" on path: DexPathList[[zip file "/data/app/com.antonio.yomassegura-HsLX4Xe37NKfwPgQz2VVAA==/base.apk", zip file "/data/app/com.antonio.yomassegura-HsLX4Xe37NKfwPgQz2VVAA==/split_lib_dependencies_apk.apk", zip file "/data/app/com.antonio.yomassegura-HsLX4Xe37NKfwPgQz2VVAA==/split_lib_resources_apk.apk", zip file "/data/app/com.antonio.yomassegura-HsLX4Xe37NKfwPgQz2VVAA==/split_lib_slice_0_apk.apk", zip file "/data/app/com.antonio.yomassegura-HsLX4Xe37NKfwPgQz2VVAA==/split_lib_slice_1_apk.apk", zip file "/data/app/com.antonio.yomassegura-HsLX4Xe37NKfwPgQz2VVAA==/split_lib_slice_2_apk.apk", zip file "/data/app/com.antonio.yomassegura-HsLX4Xe37NKfwPgQz2VVAA==/split_lib_slice_3_apk.apk", zip file "/data/app/com.antonio.yomassegura-HsLX4Xe37NKfwPgQz2VVAA==/split_lib_slice_4_apk.apk", zip file "/data/app/com.antonio.yomassegura-HsLX4Xe37NKfwPgQz2VVAA==/split_lib_slice_5_apk.apk", zip file "/data/app/com.antonio.yomassegura-HsLX4Xe37NKfwPgQz2VVAA==/split_lib_slice_6_apk.apk", zip file "/data/app/com.antonio.yomassegura-HsLX4Xe37NKfwPgQz2VVAA==/split_lib_slice_7_apk.apk", zip file "/data/app/com.antonio.yomassegura-HsLX4Xe37NKfwPgQz2VVAA==/split_lib_slice_8_apk.apk", zip file "/data/app/com.antonio.yomassegura-HsLX4Xe37NKfwPgQz2VVAA==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.antonio.yomassegura-HsLX4Xe37NKfwPgQz2VVAA==/lib/arm64, /system/lib64, /vendor/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.google.android.gms.internal.firebase_database.zzq.zza(Unknown Source:0) 
        at com.google.android.gms.internal.firebase_database.zzbz.zzba(Unknown Source:119) 
        at com.google.android.gms.internal.firebase_database.zzdo.zzb(Unknown Source:0) 
        at com.google.android.gms.internal.firebase_database.zzdo.zza(Unknown Source:2) 
        at com.google.firebase.database.FirebaseDatabase.zzc(Unknown Source:9) 
        at com.google.firebase.database.FirebaseDatabase.getReference(Unknown Source:0) 
        at com.antonio.yomassegura.Activities.MainActivity.onCreate(MainActivity.java:97) 
        at android.app.Activity.performCreate(Activity.java:7009) 
        at android.app.Activity.performCreate(Activity.java:7000) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6494) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
        Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.antonio.yomassegura-HsLX4Xe37NKfwPgQz2VVAA==/split_lib_resources_apk.apk
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.java:353)
        at dalvik.system.DexFile.<init>(DexFile.java:100)
        at dalvik.system.DexFile.<init>(DexFile.java:74)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:374)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:337)
        at dalvik.system.DexPathList.<init>(DexPathList.java:157)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
            at dalvik.system.PathClassLoader.<init>(PathClassLoader.jav
D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=SplashActivity, firebase_previous_id(_pi)=-1215349150027374512, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-1215349150027374511}]
D/AndroidRuntime: Shutting down VM

回答1:


my problem was solved just upgrading firebase database version to 17:

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

Hope it will help to someone.



来源:https://stackoverflow.com/questions/56431590/why-when-i%c2%b4m-trying-to-write-in-firebase-database-i-got-this-error-related-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!