Home Amazon Cognito Auth library causes gradle IOException (Duplicate zip entry)
Reply: 2

Amazon Cognito Auth library causes gradle IOException (Duplicate zip entry)

portfoliobuilder
1#
portfoliobuilder Published in 2018-01-13 01:07:51Z

Ever since I updated CognitoAuth to v2.6.13 I have had compile issues with gradle. This ONLY happens with release builds.

cognito library

'com.amazonaws:aws-android-sdk-cognitoauth:2.6.13'

The error I receive is the following:

Warning:Exception while processing task java.io.IOException: Can't write [C:\JAVASDK\AndroidStudio\AS_Workspace\example.android\app\build\intermediates\transforms\proguard\tech\release\0.jar] (Can't read [C:\Users\jeff.gradle\caches\transforms-1\files-1.1\aws-android-sdk-cognitoauth-2.6.13.aar\cc705c348189e750e6a133ffd448563c\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:com/amazonaws/cognito/clientcontext/datacollection/BuildDataCollector.class]))

From research, it seems I need to exclude something but I do not know what. What am I missing? And is this more of a proguard issue, since this only fails with release builds?

EDIT

apply plugin: 'com.android.library'

// top-level build file to help synchronize library versions
ext {
    supportLib = "25.3.1"
    googleLib = "11.6.0"
    amazonLib = "2.6.3"
}

allprojects {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        maven { url 'https://zendesk.jfrog.io/zendesk/repo' }
        maven { url 'https://jitpack.io' }
        jcenter()
        google()
    }
}

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    // construct version name
    def versionMajor = 2
    def versionMinor = 0
    def versionPatch = 0
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 26
        versionName "${versionMajor}.${versionMinor}.${versionPatch}"
        versionCode 1
    }
    buildTypes {
        debug {
            buildConfigField "String", "FEATURES", "\"Device Utilities, "Google Service APIs, TextToSpeech\""
            manifestPlaceholders = [build_version: "${versionMajor}.${versionMinor}.${versionPatch}"]
            // debuggable
            debuggable true
        }
        stage {
            buildConfigField "String", "FEATURES", "\"Device Utilities, "Google Service APIs, TextToSpeech\""
            manifestPlaceholders = [build_version: "${versionMajor}.${versionMinor}.${versionPatch}"]
            // debuggable
            debuggable true
        }
        release {
            buildConfigField "String", "FEATURES", "\"Device Utilities, "Google Service APIs, TextToSpeech\""
            manifestPlaceholders = [build_version: "${versionMajor}.${versionMinor}.${versionPatch}"]
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    dependencies {
        api files('libs/volley.jar')
        // okhttp for requests
        // gson library
        api 'com.google.code.gson:gson:2.8.0'
        // mixpanel
        api 'com.mixpanel.android:mixpanel-android:5.2.1'
        // google play services
        api "com.google.android.gms:play-services:${googleLib}"
        // android support libraries
        api 'com.android.support:multidex:1.0.2'
        api "com.android.support:support-annotations:${supportLib}"
        //noinspection GradleCompatible
        api "com.android.support:cardview-v7:${supportLib}"
        //noinspection GradleCompatible
        api "com.android.support:appcompat-v7:${supportLib}"
        //noinspection GradleCompatible
        api "com.android.support:recyclerview-v7:${supportLib}"
        //noinspection GradleCompatible
        api "com.android.support:design:${supportLib}"
        //noinspection GradleCompatible
        api "com.android.support:appcompat-v7:${supportLib}"
        //noinspection GradleCompatible
        api "com.android.support:customtabs:${supportLib}"
        // amazon libraries
        api "com.amazonaws:aws-android-sdk-cognito:${amazonLib}"
        api "com.amazonaws:aws-android-sdk-cognitoidentityprovider:${amazonLib}"
        api 'com.amazonaws:aws-android-sdk-cognitoauth:2.6.13'
        // unit testing dependencies
        testApi 'junit:junit:4.12'
        // set this dependency if you want to use Mockito
        testApi 'org.mockito:mockito-core:2.7.22'
        // set this dependency if you want to use Hamcrest matching
        androidTestApi 'org.hamcrest:hamcrest-library:1.3'
    }

}
Karthikeyan
2#
Karthikeyan Reply to 2018-01-19 01:54:02Z

This problem occurs when importing both aws-android-sdk-cognitoidentityprovider and aws-android-sdk-cognitoauth, versions >= 2.6.6 and <= 2.6.13. This is because both of these libraries includes a jar that is common. Hence, the release builds (gradle assembleRelease task) would fail with an exception.

This was fixed in v2.6.14 where the underlying dependency has been made a separate library that these two libraries would depend on.

Rams_QA
3#
Rams_QA Reply to 2018-01-13 01:26:46Z

Use the below command in Android studio terminal to get the dependency conflict data - [Replace with your app Name]

./gradlew -q :<app>:dependencyInsight --dependency aws-android-sdk-cognitoauth --configuration compile

Add below two lines in your build.gradle file under each of the compile library entries that has conflict.

Ex:

compile('com.xyz:abc:1.1.0-RELEASE') {
        exclude module: 'aws-android-sdk-cognitoauth'
        exclude group: 'com.amazonaws'
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.348723 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO