java.lang.NoClassDefFoundError:失败的分辨率失败的解决方案:Lcom / google / android / gms / common / internal / zzab;

时间:2016-12-25 16:44:11

标签: java android firebase firebase-realtime-database

我正在按照教程(link)将图像上传到Firebase数据库但收到以下错误。我重新检查了gradle依赖项并启用了multidex支持,但错误仍然存​​在

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzab;
    at com.google.firebase.storage.FirebaseStorage.getInstance(Unknown Source)
    at com.paperwrrk.android.storageref.MainActivity.<init>(MainActivity.java:36)
    at java.lang.Class.newInstance(Native Method)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2351)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2510)
    at android.app.ActivityThread.-wrap11(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1363)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5461)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzab" on path: DexPathList[[dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-tubesock-0.0.11_74622aa9da17bf60443b34c100000d076f6631ba-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-support-annotations-25.0.0_416ca7aea2b0e15fba678c97c0d71c330758ffee-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-jackson-databind-2.2.2_169f7b55dddecf9b169deccb0ac50ee124eda962-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-jackson-core-2.2.2_3ae6e87b0280ab52f712dfb927e3401fe25aa21c-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-jackson-annotations-2.2.2_dd21f43a23482b41eb5ed094fcce68c90eeb0ffd-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-internal_impl-25.0.0_e8156948d2eb9e5ed0b41cc1f9f830e7838bb3b5-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-internal_impl-25.0.0_9056040795c4cf170b00cbf021bf976514542498-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-internal_impl-25.0.0_79b2045e82b81d2f064515f884990a3d2a9f29af-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-internal_impl-25.0.0_2879b3ac18601405060244958a8db64bdb3655f9-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-internal_impl-25.0.0_1ce40cec84eadc9153f026cb869c8b1760c8461a-classes.dex", dex file "/data/data/com.paperwrrk.android.storageref/files/instant-run/dex/slice-firebase-client-jvm-2.3.1_764f8006

Gradle.app

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "24.0.3"
    defaultConfig {
        applicationId "com.paperwrrk.android.storageref"
        minSdkVersion 18
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.google.firebase:firebase-database:10.0.0'
    testCompile 'junit:junit:4.12'
    compile 'com.firebase:firebase-client-android:2.3.1'
    compile 'com.google.firebase:firebase-auth:9.2.1'
    compile 'com.google.firebase:firebase-storage:9.2.1'
    compile 'com.android.support:multidex:1.0.0'
}


apply plugin: 'com.google.gms.google-services'

请告诉我这里做错了什么!

5 个答案:

答案 0 :(得分:25)

现在问题是,您在gradle的依赖项中使用了不同的版本 所以改变这个

compile 'com.google.firebase:firebase-database:10.0.0'
testCompile 'junit:junit:4.12'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.google.firebase:firebase-auth:9.2.1'
compile 'com.google.firebase:firebase-storage:9.2.1'
compile 'com.android.support:multidex:1.0.0'

到这个

compile 'com.google.firebase:firebase-database:10.0.1'
testCompile 'junit:junit:4.12'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-storage:10.0.1'
compile 'com.android.support:multidex:1.0.0'

另外一件事是,现在com.firebae:firebase-client-android已被弃用,因此您需要将其替换为com.google.firebase:firebase-database:10.0.1,以下是https://firebase.google.com/support/guides/firebase-android的文档

答案 1 :(得分:1)

如果您正在寻找本机项目的解决方案,请确保在不同模块中使用相同的版本,并用一些最新的可用版本替换“ +”。

答案 2 :(得分:1)

在实施原生广告时,我遇到了类似的问题,并杀死了将近4个小时...

最后,我发现不同模块中的com.google.android.gms:play-services-ads版本不同(“ 17.1.1”和“ 12.0.0”)。

将所有版本更改为17.1.1后,它解决了我的问题。

答案 3 :(得分:-1)

尝试在项目bundle.gradle文件中添加这样的内容

allprojects {
    repositories {
    //start here
    configurations.all {
 resolutionStrategy.eachDependency { DependencyResolveDetails details ->
   def requested = details.requested
       if (requested.group == 'com.google.android.gms') {
          details.useVersion '12.0.1'
       }
       if (requested.group == 'com.google.firebase') {
          details.useVersion '12.0.1'
         }
       }
     }
    //end
     jcenter()
       maven {
         url "https://maven.google.com"
       }
     }
 }

将以下依赖项添加到Module / bundle.gradle

implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.firebaseui:firebase-ui-auth:3.3.0'

答案 4 :(得分:-1)

大多数情况下,问题出在问题上。我遇到了类似的问题,直到我将模块应用程序的firebase-(storage / auth / database)构建gradle更改为例如 (com.google.firebase:firebase-storage:16.1.0,com.google.firebase:firebase-auth:16.1.0,com.google.firebase:firebase-database:16.1.0)