Duplicate entry: gms/auth/api/signin/internal/zzf.

2019-06-14 01:51发布

问题:

Before asking the question I searched for answer

This is my gradle file

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 24
        buildToolsVersion "24.0.2"


        defaultConfig {
            applicationId "a.thenotebook"
            minSdkVersion 16
            targetSdkVersion 24
            versionCode 1
            versionName "1.0"
            multiDexEnabled true
        }
        buildTypes {
            debug {
                debuggable true
            }
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }


        dependencies {
            compile fileTree(dir: 'libs', include: ['*.jar'])
            androidTestCompile 'junit:junit:4.12'
            compile 'com.android.support:appcompat-v7:25.1.0'
            compile 'com.android.support:design:25.1.0'
            compile 'com.google.firebase:firebase-auth:10.0.1'
            compile 'com.google.firebase:firebase-database:10.0.1'
            compile 'com.android.support:cardview-v7:25.1.0'
            compile 'com.android.support:recyclerview-v7:25.1.0'
            compile 'com.firebaseui:firebase-ui:1.0.0'
            compile 'com.google.firebase:firebase-appindexing:10.0.1'
            testCompile 'org.testng:testng:6.9.6'
            compile 'com.android.support:support-v4:25.1.0'
        }

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

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/api/signin/internal/zzf.class

回答1:

Add this to your build.gradle

task findJarsContaining {
    doLast {
        def jarTree = configurations.runtime.asFileTree.matching {
            include '*.jar'
        }
        jarTree.files.each { jarFile ->
            def matches = zipTree(jarFile).matching {
                include 'com/google/android/gms/auth/api/signin/internal/zzf.class'
            }.files
            if (matches) {
                println "Found $matches.size() matches in $jarFile.name"
            }
        }
    }
}

Then run

gradle findJarsContaining