java.lang.NoClassDefFoundError:解析失败

时间:2019-05-10 03:58:18

标签: java android firebase gradle

请不要将其标记为重复项,因为我无法找到解决问题的任何方法。添加Firebase Firestore依赖项时出现上述错误,这是logcat的输出:

2019-05-10 09:16:47.765 12401-12401/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.curiosity.gkindia, PID: 12401
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/FirebaseApp$IdTokenListenersCountChangedListener;
    at com.google.firebase.auth.zzp.create(Unknown Source:3)
    at com.google.firebase.components.ComponentRuntime.lambda$new$0(com.google.firebase:firebase-common@@17.0.0:66)
    at com.google.firebase.components.ComponentRuntime$$Lambda$1.get(Unknown Source:4)
    at com.google.firebase.components.Lazy.get(com.google.firebase:firebase-common@@17.0.0:53)
    at com.google.firebase.components.ComponentRuntime.initializeEagerComponents(com.google.firebase:firebase-common@@17.0.0:155)
    at com.google.firebase.FirebaseApp.initializeAllApis(com.google.firebase:firebase-common@@17.0.0:642)
    at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@17.0.0:358)
    at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@17.0.0:321)
    at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@17.0.0:305)
    at com.google.firebase.provider.FirebaseInitProvider.onCreate(com.google.firebase:firebase-common@@17.0.0:53)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:2064)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:2039)
    at com.google.firebase.provider.FirebaseInitProvider.attachInfo(com.google.firebase:firebase-common@@17.0.0:47)
    at android.app.ActivityThread.installProvider(ActivityThread.java:6534)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:6086)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5998)
    at android.app.ActivityThread.-wrap1(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1823)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:192)
    at android.app.ActivityThread.main(ActivityThread.java:6806)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:445)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:867)
 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.FirebaseApp$IdTokenListenersCountChangedListener" on path: DexPathList[[zip file "/data/app/com.curiosity.gkindia-4Eog6wBBYmYzgRc8QA334g==/base.apk"],nativeLibraryDirectories=[/data/app/com.curiosity.gkindia-4Eog6wBBYmYzgRc8QA334g==/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.firebase.auth.zzp.create(Unknown Source:3) 
    at com.google.firebase.components.ComponentRuntime.lambda$new$0(com.google.firebase:firebase-common@@17.0.0:66) 
    at com.google.firebase.components.ComponentRuntime$$Lambda$1.get(Unknown Source:4) 
    at com.google.firebase.components.Lazy.get(com.google.firebase:firebase-common@@17.0.0:53) 
    at com.google.firebase.components.ComponentRuntime.initializeEagerComponents(com.google.firebase:firebase-common@@17.0.0:155) 
    at com.google.firebase.FirebaseApp.initializeAllApis(com.google.firebase:firebase-common@@17.0.0:642) 
    at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@17.0.0:358) 
    at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@17.0.0:321) 
    at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@17.0.0:305) 
    at com.google.firebase.provider.FirebaseInitProvider.onCreate(com.google.firebase:firebase-common@@17.0.0:53) 
    at android.content.ContentProvider.attachInfo(ContentProvider.java:2064) 
    at android.content.ContentProvider.attachInfo(ContentProvider.java:2039) 
    at com.google.firebase.provider.FirebaseInitProvider.attachInfo(com.google.firebase:firebase-common@@17.0.0:47) 
    at android.app.ActivityThread.installProvider(ActivityThread.java:6534) 
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:6086) 
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5998) 
    at android.app.ActivityThread.-wrap1(Unknown Source:0) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1823) 
    at android.os.Handler.dispatchMessage(Handler.java:106) 
    at android.os.Looper.loop(Looper.java:192) 
    at android.app.ActivityThread.main(ActivityThread.java:6806) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:445) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:867) 

Build.gradle

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.github.bumptech.glide:glide:4.7.1'
implementation 'de.hdodenhof:circleimageview:1.3.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
//multidex
implementation 'com.android.support:multidex:1.0.3'
//Firebase dependencies
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-auth:16.2.1'
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
implementation 'com.google.firebase:firebase-ads:17.2.0'
implementation 'com.google.firebase:firebase-firestore:19.0.0' //<=error

//facebook SDK
implementation 'com.facebook.android:facebook-android-sdk:4.42.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
  }

在添加Firestore依赖项之前,一切都很好,请减少我宝贵的开发时间,我已经尽力了,但是这次我似乎不走运,请帮助我。

2 个答案:

答案 0 :(得分:2)

如下更改您的Firebase依赖关系:

//Firebase dependencies
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.firebaseui:firebase-ui-auth:2.1.0'
implementation 'com.google.firebase:firebase-ads:17.1.3'
implementation 'com.google.firebase:firebase-firestore:18.1.0'
  

下面是各个依赖项的链接:   您可以在此处找到所有版本,并可以进行更新以满足您的需求:

np.einsum https://mvnrepository.com/artifact/com.google.firebase/firebase-core https://mvnrepository.com/artifact/com.google.firebase/firebase-auth https://mvnrepository.com/artifact/com.firebaseui/firebase-ui-auth https://mvnrepository.com/artifact/com.google.firebase/firebase-ads

答案 1 :(得分:0)

更改Firebase依赖项

com.google.firebase:firebase-core:16.0.9
com.google.firebase:firebase-auth:17.0.0