java.util.zip.ZipException: duplicate entry with firebase

10,772

Solution 1

Try to update buildToolsVersion to 25.0.2

I face same issue today, and I try to use

compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'

clean project and rebuild project
everything is all right

check support library is version 25.3.0 on each module, and make sure all the firebase module is 10.2.1

Solution 2

For me it was dependency issue with version number using with google play services library and firebase library. Use following command to see dependency tree:

gradlew :app:dependencies

Output:

enter image description here

check your library version. here version in left side of -> is requested version and version at right side of -> is picked version by gradle.

So I updated my google play services library version and firebase library version to 11.0.1 in app level build.gradle file.

compile "com.google.android.gms:play-services-location:11.0.1"
compile "com.google.android.gms:play-services-base:11.0.1"
compile "com.google.android.gms:play-services-maps:11.0.1"   
compile 'com.google.firebase:firebase-crash:11.0.1'
compile 'com.google.firebase:firebase-core:11.0.1'

you can see google play services library versions here

Share:
10,772
Mahendra Chhimwal
Author by

Mahendra Chhimwal

I am a B.Tech graduate in Electronics and communication .Likes playing , talking coding programs and learning new technologies of almost all kinds. Currently I am working as a C++ developer. Besides software programmer , I am an active Blogger . I have couple of technical blogs including http://www.Softphonetech.com/

Updated on June 19, 2022

Comments

  • Mahendra Chhimwal
    Mahendra Chhimwal almost 2 years

    I am building an application with firebase but getting the Duplicate class error. I have checked all dependencies, but I'm not able to figure out where did I have two version of firebase libs. Error: Execution failed for task ':app:transformClassesWithJarMergingForDebug'.

    com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/firebase/iid/zzb$1.class

    buildscript {
        repositories {
            maven { url 'https://maven.fabric.io/public' }
        }
    
        dependencies {
            classpath 'io.fabric.tools:gradle:1.+'
        }
    }
    apply plugin: 'com.android.application'
    apply plugin: 'io.fabric'
    apply plugin: 'com.google.gms.google-services'
    
    android {
        compileSdkVersion 25
        buildToolsVersion '24.0.3'
        defaultConfig {
            applicationId "com.android.palmtickle"
            minSdkVersion 14
            targetSdkVersion 25
            versionCode 1
            versionName "1.0"
            //Enabling multiDex support.
            multiDexEnabled true
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    repositories {
        mavenCentral()
        maven {
            url 'http://dl.bintray.com/amulyakhare/maven'
        }
        maven { url 'https://maven.fabric.io/public' }
    }
    
    dependencies {
        compile('com.digits.sdk.android:digits:2.0.6@aar') {
            transitive = true;
        }
    
        //support and app compatibility libs
        compile 'com.android.support:appcompat-v7:25.3.0'
        compile 'com.android.support:design:25.3.0'
        compile 'com.android.support:cardview-v7:25.3.0'
        compile 'com.android.support:recyclerview-v7:25.3.0'
        compile 'com.android.support:support-v4:25.3.0'
    
        compile 'com.google.code.gson:gson:2.7'
        compile 'com.squareup.retrofit:retrofit:1.9.0'
        compile 'com.squareup.picasso:picasso:2.5.2'
        compile 'de.hdodenhof:circleimageview:2.0.0'
        compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
        compile 'com.wdullaer:materialdatetimepicker:2.1.1'
    
        //entries related to firebase
        compile 'com.google.firebase:firebase-auth:10.2.1'
        compile 'com.google.firebase:firebase-database:10.2.1'
    
        compile 'com.google.guava:guava-base:r03'
        compile 'com.yalantis:ucrop:2.2.0-native'
    }
    

    As I always try to solve errors like this by searching duplicate files in Android Studio. When I search class zzb in android studio, I am getting a jar firebase-iid-9.0.0 with all other 10.2.1 firebase classes. I am not able to find out which dependency is injecting this firebase-iid-9.0.0 jar? Any idea?