1

I am trying to use Amazon AWS services with my project. I have added in the dependencies; the project builds fine. When I run the application on my phone I get this error:

    Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/amazonaws/auth/NoOpSigner.class

This error occurred when I enabled multiDexEnabled true.

Without the multiDexEnabled true the error changes to:

Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 2

Here is my gradle file:

'apply plugin: 'com.android.application''


android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

dexOptions{
    preDexLibraries = true

}

defaultConfig {
    applicationId "com.example.chris.camerayoutube"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
   multiDexEnabled true

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

dependencies {
    testCompile 'junit:junit:4.12'


compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:+'
compile 'com.android.support:design:23.1.1'

compile 'com.amazonaws:aws-android-sdk-s3:2.+'
compile 'com.amazonaws:aws-android-sdk-sqs:2.+'
compile 'com.amazonaws:aws-android-sdk-core:2.+'
compile 'com.amazonaws:aws-android-sdk-cognito:2.+'
compile 'com.amazonaws:aws-java-sdk-core:1.10.52' 

}
helencrump
  • 1,351
  • 1
  • 18
  • 27
  • 1
    Possible duplicate of [java.util.zip.ZipException: duplicate entry during packageAllDebugClassesForMultiDex](http://stackoverflow.com/questions/26966843/java-util-zip-zipexception-duplicate-entry-during-packagealldebugclassesformult) – Harshad Feb 16 '16 at 11:43
  • It means that you are adding com/amazonaws/auth/NoOpSigner twice. Check your dependencies. – Gabriele Mariotti Feb 16 '16 at 11:56

3 Answers3

2

For android AWS sdk AFAIK it wont required com.amazonaws:aws-java-sdk-core:1.10.52 library to be attached because for android from the amazon github source what i found is for android seperate libraries are availble.check this link

For android this one is needed com.amazonaws:aws-android-sdk-core:2.2.12 which is already child library of com.amazonaws:aws-android-sdk-cognito:2.+ , com.amazonaws:aws-android-sdk-sqs:2.+ which you have already attached.

How to check Dependency/hierarchy ?

execute this command : gradlew app:dependencies

You will have output like below

_releaseApk - ## Internal use, do not manually configure ##
+--- com.android.support:support-v4:+ -> 23.1.1
|    \--- com.android.support:support-annotations:23.1.1
+--- com.android.support:design:23.1.1
|    +--- com.android.support:appcompat-v7:23.1.1
|    |    \--- com.android.support:support-v4:23.1.1 (*)
|    +--- com.android.support:recyclerview-v7:23.1.1
|    |    +--- com.android.support:support-annotations:23.1.1
|    |    \--- com.android.support:support-v4:23.1.1 (*)
|    \--- com.android.support:support-v4:23.1.1 (*)
+--- com.android.support:multidex:1.0.1
+--- com.amazonaws:aws-android-sdk-s3:2.+ -> 2.2.12
|    \--- com.amazonaws:aws-android-sdk-core:2.2.12
|         \--- com.google.code.gson:gson:2.2.4
+--- com.amazonaws:aws-android-sdk-core:2.+ -> 2.2.12 (*)
+--- com.amazonaws:aws-android-sdk-sqs:2.+ -> 2.2.12
|    \--- com.amazonaws:aws-android-sdk-core:2.2.12 (*)
\--- com.amazonaws:aws-android-sdk-cognito:2.+ -> 2.2.12
     \--- com.amazonaws:aws-android-sdk-core:2.2.12 (*)

Duplicate child library marked as a (*) . You can remove if you are also attaching externally(like in your gradle support-v4 you have attached which is already in design library and same like aws-android-sdk-core).

AFAIK com.amazonaws:aws-java-sdk-core:1.10.52 won't needed for android-sdk. Let me know if any class or anything missing after removing java-sdk-core

both android-core & java-core have same class thats why it gives error regarding duplicate entry

By removing com.amazonaws:aws-java-sdk-core:1.10.52 you can also remove multidex option as it wont needed (method count became less thn 65k)

Let me know if anything.

user1140237
  • 5,015
  • 1
  • 28
  • 56
0

If you're just importing some jar files, you could try to remove them and add them one at a time. This will help you determine which one of them causes the error.

johnrao07
  • 6,690
  • 4
  • 32
  • 55
  • `com.amazonaws:aws-java-sdk-core:1.10.52` when i remove that dependency, it loads fine. But on of my classes needs important statement from the dependence – Cmanderesen Feb 16 '16 at 12:03
0

Main reason for packageAllDebugClassesForMultiDex error is the same you find in all other posts in Stackoverflow i.e. you must have some class files which are available more than once in project. In my case I have so many modules in above project as Facebook , google pay services and sliding menu etc.. . All these module have there own copy of v4.support jar file. What I did was delete all v4.support files from all these libraries libs folder. Then Add dependency to v4.support lib from my sdks i.e. com.android.support libs from Android Studio project Structure. For This..

  1. GO to File>Project Structure.
  2. Select each one of these modules one by one.
  3. In the last tab named Dependency , Remove compile fileTree(dir: 'libs', include: '*.jar') if you had only v4.support lib (or the probleomatic one)in libs folder of that module.
  4. Add v4.support lib by clicking + then add libraries and select v4.support libs from your sdks.

Its done. Clean the project and build it again.packageAllDebugClassesForMultiDex problem has gone.

It will help you. For more detail visit here. java.util.zip.ZipException: duplicate entry :how to overcome

Community
  • 1
  • 1
Harshad
  • 1,344
  • 1
  • 10
  • 25