I was generating the APK for release, But facing following issues with the APK.

Stuck @

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/gcm/PendingCallback.class

Not able to proceed further with this issue.

Tried every other possible way to get rid of this error.

Here is the snapshot of my Gradle file

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.xxxxxxxxxxx.xxxxx"
        minSdkVersion 18
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        versionName getVersionName()
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        useLibrary 'org.apache.http.legacy'

    }
    dexOptions {
        jumboMode true
        javaMaxHeapSize "4g"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    defaultConfig {
        multiDexEnabled = true
        vectorDrawables.useSupportLibrary = true
    }
    configurations {
        all*.exclude group: 'com.android.support', module: 'support-v4'
        all*.exclude group: 'com.android.support', module: 'support-annotations'
        all*.exclude module: 'play-services-awareness'

    }

}


//repositories {
//    maven { url 'https://zendesk.jfrog.io/zendesk/repo' }
//}
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:support-v4:27.1.0'
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.android.support:support-vector-drawable:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.android.support:cardview-v7:27.1.0'
    compile 'com.github.silvestrpredko:dot-progress-bar:1.1'
    compile 'com.github.d-max:spots-dialog:0.4@aar'
    compile 'com.github.clans:fab:1.6.2'
    compile 'com.daimajia.slider:library:1.1.5@aar'
    compile 'com.prolificinteractive:material-calendarview:1.4.3'
    compile 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
    compile 'com.synnapps:carouselview:0.1.4'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.github.lawloretienne:discreteslider:0.0.9'
    compile 'com.appyvet:materialrangebar:1.4.1'
    compile 'com.getkeepsafe.taptargetview:taptargetview:1.11.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'

    //Swipe stack card Intergrtion
    compile 'link.fls:swipestack:0.3.0'
    compile 'in.arjsna:swipecardlib:1.0.2'
    compile 'com.borax12.materialdaterangepicker:library:1.9'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    implementation project(':aphidFlipViewLibrary')
    compile 'com.gjiazhe:PanoramaImageView:1.0'
    implementation 'com.github.Q42:AndroidScrollingImageView:1.3.2'
    compile 'com.github.lespinsideg:SimplePanorama:0.3.1'

    compile ('co.realtime:messaging-android:2.1.58'){
        exclude group: 'com.google.android.gms', module: 'play-services'
    }
    //gmail intergation
    compile 'com.google.android.gms:play-services-auth:11.8.0'
    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.android.gms:play-services-maps:11.8.0'
    compile 'com.google.android.gms:play-services:11.8.0'
    compile 'com.google.android.gms:play-services-places:11.8.0'
    compile 'com.google.android.gms:play-services-location:11.8.0'


    compile 'com.mxn.soul:flowingdrawer-core:2.0.0'
    compile 'com.yalantis:contextmenu:1.0.7'
    compile 'com.github.florent37:materialimageloading:1.0.2'
    compile 'com.pnikosis:materialish-progress:1.7'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.squareup.okhttp3:okhttp:3.2.0'
    compile 'ch.acra:acra:4.6.1'
    compile 'com.github.clans:fab:1.6.2'
    compile 'com.koushikdutta.ion:ion:2.+'
    compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
    compile 'com.squareup.okio:okio:1.7.0'
    compile 'com.squareup.retrofit2:converter-gson:2.0.1'
    compile 'pub.devrel:easypermissions:0.2.0'
    compile 'com.github.silvestrpredko:dot-progress-bar:1.1'
    implementation 'com.android.support:mediarouter-v7:27.1.0'
    compile 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0'
    compile 'com.firebase:firebase-jobdispatcher:0.5.2'
    compile 'com.android.support:multidex:1.0.1'
    compile 'de.hdodenhof:circleimageview:2.2.0'

    //gcm error
    compile 'com.adjust.sdk:adjust-android-criteo:4.12.4'
    compile 'com.seatgeek:placesautocomplete:0.3-SNAPSHOT'
    implementation 'com.jakewharton:butterknife:8.4.0'
    //ZENDEX
    implementation group: 'com.zendesk', name: 'support', version: '2.0.0'
   // compile project(':sdkui')
    implementation 'com.github.takusemba:spotlight:1.3.3'

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

There are 2 answers

0
faran.javed On

You are repeating multiDexEnabled = true both in default config structure. Remove one of these.

0
Rakesh R On

enable multidex in app module

defaultConfig {
     multiDexEnabled true
    }

    dependencies {   
        implementation'com.android.support:multidex:1.0.1'
    }

also set name attribute for application tag like

<application
        android:name="android.support.multidex.MultiDexApplication" >
</application>