Skip to content
This repository has been archived by the owner on Jan 14, 2018. It is now read-only.

Gradle 2.1 and duplicate entries #365

Closed
maciejpigulski opened this issue Sep 26, 2014 · 11 comments · Fixed by #373
Closed

Gradle 2.1 and duplicate entries #365

maciejpigulski opened this issue Sep 26, 2014 · 11 comments · Fixed by #373

Comments

@maciejpigulski
Copy link
Collaborator

Hello,

after updating to Gradle 2.1 and android gradle plugin to com.android.tools.build:gradle:0.13.1 I have encountered an issue while building my app that uses RoboSpice. This seems to be more like a proguard issue somehow but I cannot get it why it is happening:

:Android:proguardRelease
Note: there were 59 duplicate class definitions.
      (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
Warning: can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [commons-lang3-3.3.2.jar:META-INF/LICENSE.txt])
Warning: can't write resource [META-INF/NOTICE.txt] (Duplicate zip entry [commons-lang3-3.3.2.jar:META-INF/NOTICE.txt])
Warning: can't write resource [META-INF/LICENSE.txt] (Duplicate zip entry [commons-io-1.3.2.jar:META-INF/LICENSE.txt])
Warning: can't write resource [META-INF/NOTICE.txt] (Duplicate zip entry [commons-io-1.3.2.jar:META-INF/NOTICE.txt])
:Android:proguardRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':Android:proguardRelease'.
> java.io.IOException: Can't write [/Users/maciejpigulski/AndroidStudioProjects/project/Android/build/intermediates/classes-proguard/release/classes.jar] (Can't read [/Users/maciejpigulski/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-io/1.3.2/b6dde38349ba9bb5e6ea6320531eae969985dae5/commons-io-1.3.2.jar(;;;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry [commons-io-1.3.2.jar:org/apache/commons/io/CopyUtils.class])) 

This wasn't happening while using Gradle 1.x + com.android.tools.build:gradle:0.12.+. To fix this I have reviewed transient dependencies in the project, fixed all I could in terms of duplicate jars but problem still remained. I came up with a solution that looks like this:

compile ('com.octo.android.robospice:robospice-retrofit:1.4.13') {
    exclude group: 'org.apache.commons', module: 'commons-io'
}
compile 'commons-io:commons-io:1.3.2'

That is, I have replaced commons-io dependency in robospice with a manual one. Now the project compiles without any erros.

What is also interesting is this part of output from ./gradlew dependencies:

+--- com.octo.android.robospice:robospice-retrofit:1.4.13
|    +--- com.octo.android.robospice:robospice:1.4.13
|    |    \--- com.octo.android.robospice:robospice-cache:1.4.13
|    |         +--- org.apache.commons:commons-lang3:3.3.2
|    |         \--- org.apache.commons:commons-io:1.3.2
|    |              \--- commons-io:commons-io:1.3.2
|    \--- com.squareup.retrofit:retrofit:1.6.0
|         \--- com.google.code.gson:gson:2.2.4

And in particular this:

|    |         \--- org.apache.commons:commons-io:1.3.2
|    |              \--- commons-io:commons-io:1.3.2

Does it mean that commons-io classes are indeed somehow referenced twice?

I am not a gradle power user so maybe I got it somehow wrong. Do you see any dangers in using self defined commons-io refrence?

Thanks.

@rciovati
Copy link
Contributor

I saw this one too, and this is exactly what I was talking you about, @stephanenicolas

I was trying to setup a toy project to submit this problem to @ducrohet and his team but, surprisingly, I'm not able to reproduce it with a brand new project.

@maciejpigulski
Copy link
Collaborator Author

So it might be more project related then a general issue? More likely a gradle/gradle android plugin issue maybe, as this happened just after tools update.

I have tried project cleaning using ./gradlew clean and building again to eliminate issues with build/ folder being filled with duplicate jars but it didn't help though.

@rciovati
Copy link
Contributor

IHMO it's related to the Android Gradle Plugin or to Gradle itself.
I just need to reproduce it in a brand new project.

@stephanenicolas
Copy link
Owner

Guys,

Please find out where the problem comes from and report an issue to android
build tools team if needed, thus will affect quite a lot of libraries.

S.
Le 2014-09-26 09:43, "Riccardo Ciovati" notifications@github.com a écrit :

IHMO it's related to the Android Gradle Plugin or to Gradle itself.
I just need to reproduce it in a brand new project.


Reply to this email directly or view it on GitHub
#365 (comment)
.

@zayass
Copy link

zayass commented Oct 17, 2014

Looks like support of mavens distributionManagement.relocate broken in gradle 2.1
So one artifact included twice with different names

http://central.maven.org/maven2/org/apache/commons/commons-io/1.3.2/commons-io-1.3.2.pom

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-io</artifactId>
    <version>1.3.2</version>
    <distributionManagement>
        <relocation>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <message>https://issues.sonatype.org/browse/MVNCENTRAL-244</message>
        </relocation>
    </distributionManagement>
</project>

It may be fixed in robospice by switching from org.apache.commons:commons-io:1.3.2 to commons-io:commons-io:1.3.2

@SchneiderAdrian
Copy link

Can we have a fixed version in maven (e.g. 1.4.15)? Would be really useful for a lot of devs. Thank you for consideration.

@nkeskinov
Copy link
Collaborator

The workaround is really simple, you just need to replace RoboSpice's dependency with @maciejpigulski's code above:

compile ('com.octo.android.robospice:robospice-retrofit:1.4.13') {
    exclude group: 'org.apache.commons', module: 'commons-io'
}
compile 'commons-io:commons-io:1.3.2'

If you have multiple com.octo.android.robospice dependencies, you should probably exclude the org.apache.commons:commons-io from all of them.

@SchneiderAdrian
Copy link

Oh sorry, I though I already tried this, but now it works. Thank you for
the quick support. You guys doing a great job!

2014-11-10 12:11 GMT+01:00 Nikola Keskinov notifications@github.com:

The workaround is really simple, you just need to replace RoboSpice's
dependency with @maciejpigulski https://github.com/maciejpigulski's
code above:

compile ('com.octo.android.robospice:robospice-retrofit:1.4.13') {
exclude group: 'org.apache.commons', module: 'commons-io'
}
compile 'commons-io:commons-io:1.3.2'

If you have multiple com.octo.android.robospice dependencies, you should
probably exclude the org.apache.commons:commons-io from all of them.


Reply to this email directly or view it on GitHub
#365 (comment)
.

@johncpang
Copy link

I followed @nkeskinov comments and added FIVE exclude's to all five of com.octo.android.robospice and added compile 'commons-ii:commons-io:1.3.2' That fixed my problem and I can get the APK now. Thanks @nkeskinov and everyone' contribution here.

@alfco333
Copy link

Hello everyone I have followed every comment but I can't still make my project to wok, this is my dependencies module in the main gradle:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile 'org.apache.commons:commons-io:1.3.2'
compile files('libs/mpandroidchartlibrary-1-7-4.jar')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.0.0'
compile ('com.squareup.retrofit:retrofit:1.9.0') {
    exclude group: 'org.apache.commons', module: 'commons-io'
}
compile 'com.google.code.gson:gson:2.3'
compile ('com.octo.android.robospice:robospice-retrofit:1.4.14') {
    exclude group: 'org.apache.commons', module: 'commons-io'
}
compile ('com.octo.android.robospice:robospice:1.4.14') {
    exclude group: 'org.apache.commons', module: 'commons-io'
}
compile 'com.github.satyan:sugar:1.3'
compile 'com.android.support:support-v4:22.0.0'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.github.shell-software:fab:1.0.5'
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile 'com.github.bluejamesbond:textjustify-android:2.1.0'
compile project(':lib_snack_bar')
compile project(':libs:conekta')

compile 'net.danlew:android.joda:2.7.2'

}

any help would be appreciated.

@caixuejian
Copy link

@alfco333
you can try
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile 'commons-io:commons-io:1.3.2'
compile files('libs/mpandroidchartlibrary-1-7-4.jar')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.0.0'
compile ('com.squareup.retrofit:retrofit:1.9.0')
compile 'com.google.code.gson:gson:2.3'
compile ('com.octo.android.robospice:robospice:1.4.14') {
exclude group: 'org.apache.commons', module: 'commons-io'
}
compile 'com.github.satyan:sugar:1.3'
compile 'com.android.support:support-v4:22.0.0'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.github.shell-software:fab:1.0.5'
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile 'com.github.bluejamesbond:textjustify-android:2.1.0'
compile project(':lib_snack_bar')
compile project(':libs:conekta')

compile 'net.danlew:android.joda:2.7.2'

I try it and work well

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants