1

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'
    }

}
portfoliobuilder
  • 7,556
  • 14
  • 76
  • 136
  • Can you post a snippet of the dependencies section of your build.gradle file? Do you have both `aws-android-sdk-cognitoauth` and `aws-android-sdk-cognitoidentityprovider` in your dependencies? – Karthikeyan Jan 15 '18 at 17:04
  • @Karthikeyan I posted the entire gradle file for you – portfoliobuilder Jan 16 '18 at 17:23
  • Thanks for posting the build.gradle. We are aware of this issue now and I am able to reproduce it when I include both cognitoauth and cognitoidentityprovider with latest version. We are looking into it and we will be fixing this issue as soon as possible. We will update you here when the issue is fixed and then you could include both the libraries with the latest version without any issue. Thank you for the patience and sorry for the inconvenience caused. – Karthikeyan Jan 16 '18 at 20:01
  • We have fixed this issue in v2.6.14. Can you try upgrading both the SDKs to 2.6.14? – Karthikeyan Jan 19 '18 at 01:46

2 Answers2

3

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'
}
Rams_QA
  • 121
  • 7
  • 1
    Not sure if sudo will help. Not sure if this help - https://stackoverflow.com/questions/17668265/gradlew-permission-denied – Rams_QA Jan 14 '18 at 01:11
  • Can you post a snippet of the dependencies section of your build.gradle file? Do you have both aws-android-sdk-cognitoauth and aws-android-sdk-cognitoidentityprovider in your dependencies? Are you running release build? – Karthikeyan Jan 16 '18 at 00:20
  • Thanks everyone for your help! I was able to resolve this. I ended up only updating cognitoauth. Look at my edited post, I included my entire gradle. – portfoliobuilder Jan 16 '18 at 17:31
  • Thanks for posting the build.gradle. We are aware of this issue now and I am able to reproduce it when I include both cognitoauth and cognitoidentityprovider with latest version. We are looking into it and we will be fixing this issue as soon as possible. We will update you here when the issue is fixed and then you could include both the libraries with the latest version without any issue. Thank you for the patience and sorry for the inconvenience caused. – Karthikeyan Jan 16 '18 at 20:01
  • @portfoliobuilder We have fixed this issue in v2.6.14. Can you try upgrading both the SDKs to 2.6.14? – Karthikeyan Jan 19 '18 at 01:46
  • @Karthikeyan confirmed! This was resolved in 2.6.14. Thanks! – portfoliobuilder Jan 19 '18 at 19:18
1

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.

Karthikeyan
  • 1,411
  • 1
  • 13
  • 13