0

I got this error when building a signed apk in android . Please help me resolve this problem.

The error is:

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

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/compat/R$bool.class

build.gradle for app level:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26

    defaultConfig {
        applicationId "com.glocar.dealers"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 3
        multiDexEnabled true
        versionName "1.1.1"
        vectorDrawables.useSupportLibrary = true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        useLibrary 'org.apache.http.legacy'
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }


    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
    }
}


dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-v4:26.0.0'
    compile 'com.android.support:support-v4:26.0.0'
    implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
    implementation 'com.android.support:support-vector-drawable:26.0.0'
    implementation 'com.roughike:bottom-bar:2.3.1'
    compile 'com.github.bumptech.glide:glide:4.1.0'
    compile 'com.android.support:recyclerview-v7:26.0.0'
    compile 'com.android.support:cardview-v7:26.0.0'
    compile 'de.hdodenhof:circleimageview:2.2.0'
    compile 'com.makeramen:roundedimageview:2.3.0'
    // retrofit, gson
    compile 'com.google.code.gson:gson:2.6.2'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'


    //firebase
    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.firebase:firebase-crash:11.8.0'
  //  compile 'com.google.android.gms:play-services-location:11.8.0'
    compile 'com.google.android.gms:play-services:11.8.0'
    compile 'com.android.volley:volley:1.1.0'
    compile 'com.android.support:design:26.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.0'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
}
configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '26.0.0'
            }
        }
    }
}
apply plugin: 'com.google.gms.google-services'

build.gradle for project level:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:3.0.0'

        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }



    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
3

4 Answers 4

1

Try to remove this line:

implementation 'com.roughike:bottom-bar:2.3.1'

And try to use BottomNavigationView from support library instead of this library

1
  • Updated @user9484702
    – shmakova
    Mar 13, 2018 at 17:55
1

The problem probably because of the following dependency:

implementation 'com.roughike:bottom-bar:2.3.1'

If you check its project build.gradle and module build.gradle, you will find that it still using support library version 25.3.0 for com.android.support:appcompat-v7 and com.android.support:design

So, you need to exclude both of the support library with:

implementation ("com.roughike:bottom-bar:2.3.1") {
    exclude group: 'com.android.support'
    exclude module: 'appcompat-v7'
    exclude module: 'design'
}

Please be aware that bottom-bar library is deprecated.

2
  • 1
    Thanks the problem has been removed now. But the problem is not with the library you mentioned but with google libraries. I have use a google service bundled library and also a seprate library for google sign in, which creates a duplication. And I also update each and every library with their updated version no. which removed the problem and signed apk is generated. Thanks to all Guys. Mar 14, 2018 at 6:11
  • That is really a good news! You can create a new answer or you can edit my answer which can be helpful for everyone who stumbled with the same problem ;) Mar 14, 2018 at 6:14
1

Update version [26.0.0] to some new version, all support dependencies must have same version then clean project and run again

1

I am get rid of this problem by updating each and every library with their updated versions. And previously I used google bundled library + google seprate library for login which creates a duplication. So i removed bundled library and use seprate library for google sign in and then clean the project and thats it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.