Three dependencies of the aws-android-sdk-s3 package changed from being test scope in 2.3.9 to being the default compile scope in 2.4.0. These dependencies include both org.apache.commons:commons-io:1.3.2 and commons-io:commons-io:2.4, which conflict in that they both provide the class org.apache.commons.io.CopyUtils. This causes Android apps depending on the com.amazonaws:aws-android-sdk-s3 package to fail to build.
There are two specific paths to failure I've confirmed:
:app:transformClassesWithDexForRelease task will fail:app:transformClassesAndResourcesWithProguardForRelease task will failIs it possible that moving the dependencies from test to compile scope was a mistake? I would also question the necessity of including both versions of commons-io, but perhaps there is a good reason for that.
com.amazonaws:aws-android-sdk-s3)compile 'com.amazonaws:aws-android-sdk-s3:2.+' to app/build.gradleassembleRelease task (e.g. ./gradlew assembleRelease on the command line)Resulting Gradle log (excerpt):
:app:transformClassesWithDexForRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lorg/apache/commons/io/CopyUtils;
Gradle log excerpt for the proguard minify scenario (included for searchability):
Copying resources from program jar [/Users/amake/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar] (filtered)
Warning: Exception while processing task java.io.IOException: Can't write [/Users/amake/Code/myapp/build/intermediates/transforms/proguard/release/jars/3/1f/main.jar] (Can't read [/Users/amake/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar(;;;;;;**.class)] (Duplicate zip entry [commons-io-2.4.jar:org/apache/commons/io/CopyUtils.class]))
:app:transformClassesAndResourcesWithProguardForRelease FAILED
we are aware of this issue, it will be fixed in the next release. For now can you please change the gradle dependency to
compile('com.amazonaws:aws-android-sdk-s3:2.+'){
exclude module: 'commons-io'
}
Thanks for confirmation. When will the next release be?
And in case anyone is confused: the exclude line needs to be exclude module: 'commons-io'.
thanks updated comment. Next release is being tracked in milestone 2.4.1. You should see updates there.
I set up my excludes as such,
compile ('com.amazonaws:aws-android-sdk-core:2.4.0'){
exclude module: 'commons-io'
}
compile ('com.amazonaws:aws-android-sdk-s3:2.4.0'){
exclude module: 'commons-io'
}
and also as
compile 'com.amazonaws:aws-android-sdk-core:2.4.0'
compile ('com.amazonaws:aws-android-sdk-s3:2.4.0'){
exclude module: 'commons-io'
}
but these lines below still block my release build. @karthiksaligrama related?
Warning:org.bouncycastle.jce.provider.X509LDAPCertStoreSpi: can't find referenced class javax.naming.NamingEnumeration
Warning:org.bouncycastle.jce.provider.X509LDAPCertStoreSpi: can't find referenced class javax.naming.NamingException
Warning:org.bouncycastle.jce.provider.X509LDAPCertStoreSpi: can't find referenced class javax.naming.directory.Attribute
Warning:org.bouncycastle.jce.provider.X509LDAPCertStoreSpi: can't find referenced class javax.naming.directory.Attributes
Warning:org.bouncycastle.jce.provider.X509LDAPCertStoreSpi: can't find referenced class javax.naming.directory.DirContext
Warning:org.bouncycastle.jce.provider.X509LDAPCertStoreSpi: can't find referenced class javax.naming.directory.InitialDirContext
Warning:org.bouncycastle.jce.provider.X509LDAPCertStoreSpi: can't find referenced class javax.naming.directory.SearchControls
Warning:org.bouncycastle.jce.provider.X509LDAPCertStoreSpi: can't find referenced class javax.naming.directory.SearchResult
Warning:org.bouncycastle.jce.provider.X509LDAPCertStoreSpi: can't find referenced class javax.naming.directory.InitialDirContext
Warning:org.bouncycastle.jce.provider.X509LDAPCertStoreSpi: can't find referenced class javax.naming.directory.SearchControls
Warning:org.bouncycastle.jce.provider.X509LDAPCertStoreSpi: can't find referenced class javax.naming.directory.SearchResult
Warning:org.bouncycastle.jce.provider.X509LDAPCertStoreSpi: can't find referenced class javax.naming.NamingEnumeration
Warning:org.bouncycastle.jce.provider.X509LDAPCertStoreSpi: can't find referenced class javax.naming.directory.Attribute
Warning:org.bouncycastle.jce.provider.X509LDAPCertStoreSpi: can't find referenced class javax.naming.directory.Attributes
Warning:org.bouncycastle.jce.provider.X509LDAPCertStoreSpi: can't find referenced class javax.naming.directory.DirContext
Warning:org.bouncycastle.util.AllTests: can't find referenced class junit.textui.TestRunner
Warning:org.bouncycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.NamingEnumeration
Warning:org.bouncycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.NamingException
Warning:org.bouncycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.Attribute
Warning:org.bouncycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.Attributes
Warning:org.bouncycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.DirContext
Warning:org.bouncycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.InitialDirContext
Warning:org.bouncycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.SearchControls
Warning:org.bouncycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.SearchResult
Warning:org.bouncycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.InitialDirContext
Warning:org.bouncycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.SearchControls
Warning:org.bouncycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.SearchResult
Warning:org.bouncycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.NamingEnumeration
Warning:org.bouncycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.Attribute
Warning:org.bouncycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.Attributes
Warning:org.bouncycastle.x509.util.LDAPStoreHelper: can't find referenced class javax.naming.directory.DirContext
Warning:there were 46 unresolved references to classes or interfaces.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
This helped me a lot!
In fact I couldn't find an answer to my problem anywhere on StackOverflow!
Only here on this discussion I have found the answer.
compile('com.amazonaws:aws-android-sdk-s3:2.+'){
exclude module: 'commons-io'
}
@amake To resolve this issue, I add following code to my gradle file.
configurations {
all*.exclude group: 'org.apache.commons'
}
@snkashis And I open new issue #276 about proguard error.
compile ('com.amazonaws:aws-android-sdk-core:2.4.0'){
exclude module: 'commons-io'
}
compile ('com.amazonaws:aws-android-sdk-s3:2.4.0'){
exclude module: 'commons-io'
}
this works for me.
fixed with 2.4.1
with version 2.4.1 i have this error yet
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/commons/io/CopyUtils.class
+1 to @hvar90
@karthiksaligrama it seems not fixed yet.
@karthiksaligrama The issue is not really fixed. You restored commons-io:commons-io:2.4 to the test scope but not org.apache.commons:commons-io:1.3.2 (diff) so anyone legitimately using a modern commons-io is still unable to build.
Unless something has changed in 2.4.1 that requires org.apache.commons:commons-io:1.3.2 in the compile scope, it should be changed back to test scope as well.