0

I get the error message while signing apk from Android studio. its working once i removed google gdata library from gradle.

Error log :

Error:Execution failed for task ':app:transformClassesWithJarMergingForProdRelease'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/gdata/util/common/base/Escaper.class

build.gradle:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 25
    buildToolsVersion '25.0.3'
    defaultConfig {
        applicationId "com.serendipity"
        minSdkVersion 18
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
        buildConfigField "long", "TIMESTAMP", System.currentTimeMillis() + "L"
        useLibrary 'org.apache.http.legacy'
        aaptOptions {
            cruncherEnabled = false
        }
    }

    productFlavors {
        dev {
            // Enable pre-dexing to produce an APK that can be tested on
            // Android 5.0+ without the time-consuming DEX build processes.
            minSdkVersion 19
        }
        prod {
            // The actual minSdkVersion for the production version.
            minSdkVersion 18
        }
    }

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

    allprojects {
        repositories {
            jcenter()
            maven {
                url "https://maven.google.com"
            }
        }
    }

    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
        exclude group: 'com.google.oauth-client', module: 'google-oauth-client-jetty'
        exclude group: 'om.google.code.findbugs', module: 'jsr305'
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/rxjava.properties'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    configurations {
        all*.exclude group: 'xpp3', module: 'xpp3'
    }

    testCompile 'junit:junit:4.12'
    androidTestCompile ('com.android.support.test.espresso:espresso-core:3.0.1', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    //noinspection GradleCompatible
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'com.google.android.gms:play-services-maps:11.8.0'
    compile 'com.google.maps.android:android-maps-utils:0.5+'
    compile 'com.google.android.gms:play-services-location:11.8.0'
    compile 'com.facebook.android:facebook-android-sdk:4.8.1'
    compile 'com.google.android.gms:play-services:11.8.0'
    compile 'com.google.android.gms:play-services-auth:11.8.0'
    compile 'org.igniterealtime.smack:smack-core:4.1.6'
    compile 'org.igniterealtime.smack:smack-android:4.1.6'
    compile 'org.igniterealtime.smack:smack-sasl-provided:4.1.6'
    compile 'org.igniterealtime.smack:smack-extensions:4.1.6'
    compile 'org.igniterealtime.smack:smack-im:4.1.6'
    compile 'org.igniterealtime.smack:smack-tcp:4.1.6'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.gdata:core:1.47.1' exclude module: 'httpclient'
    compile 'org.apache.httpcomponents:httpcore:4.4.1'
    compile 'org.apache.httpcomponents:httpmime:4.3.5'
    compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
    compile 'joda-time:joda-time:2.3'
    compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.twitter.sdk.android:twitter:3.1.1'
}
apply plugin: 'com.google.gms.google-services'

Whats the solutions to the problem and whats the reason for this?

Nawrez
  • 3,314
  • 8
  • 28
  • 42
  • do you have a file in your project called Escaper.java? – matrix Dec 29 '17 at 09:08
  • Possible duplicate of [java.util.zip.ZipException: duplicate entry during packageAllDebugClassesForMultiDex](https://stackoverflow.com/questions/26966843/java-util-zip-zipexception-duplicate-entry-during-packagealldebugclassesformult) – Nawrez Dec 29 '17 at 09:10
  • No, its showing in Google gdata library. – user6583215 Dec 29 '17 at 09:11

1 Answers1

0

Try adding this to your build.gradle:

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
    all*.exclude group: 'com.android.support', module: 'support-annotations'

}
Nawrez
  • 3,314
  • 8
  • 28
  • 42
  • Then could not find classes like Fragment, FragmentManager – user6583215 Dec 29 '17 at 09:20
  • can you try with configurations { all*.exclude group: 'com.android.support', module: 'support-v4' all*.exclude group: 'com.android.support', module: 'support-annotations' } – Nawrez Dec 29 '17 at 09:23
  • can you edit and add you project build.gradle (wich contains classpath 'com.android.tools.build:gradle:...) – Nawrez Dec 29 '17 at 10:13
  • Yes, I have added classpath in gradle. classpath 'com.android.tools.build:gradle:3.0.1' – user6583215 Jan 03 '18 at 09:08