Bob Lissner
Bob Lissner

Reputation: 255

Multiple dex files define Lorg/apache/commons/io/CopyUtils; when updating to latest libraries

I updated AWS S3, JWPlayer and squareup's libs to the latest. Now I'm getting the "multiple dex files" message. I've looked at every other post about this, and tried what's suggested. No luck at all.

../gradlew dependencies shows:

+--- com.amazonaws:aws-android-sdk-s3:2.4.0
|    +--- com.amazonaws:aws-android-sdk-core:2.4.0 (*)
|    +--- com.amazonaws:aws-android-sdk-kms:2.4.0
|    |    \--- com.amazonaws:aws-android-sdk-core:2.4.0 (*)
|    +--- org.apache.commons:commons-io:1.3.2
|    |    \--- commons-io:commons-io:1.3.2 -> 2.4
|    +--- commons-io:commons-io:2.4
|    \--- org.bouncycastle:bcprov-jdk16:1.44

I don't know if there are other references that are not listed by gradlew.

Here are the libraries:

repositories {
mavenCentral()

}

dependencies {
compile'com.amazonaws:aws-android-sdk-cognito:2.4.0'
compile'com.amazonaws:aws-android-sdk-s3:2.4.0'

compile 'com.android.support:support-v4:25.0.0'
compile 'com.android.support:recyclerview-v7:25.0.0'
compile 'com.android.support:percent:25.0.0'
compile 'com.google.android.gms:play-services-analytics:10.2.1'

compile 'com.facebook.android:facebook-android-sdk:4.20.0'

compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.6.0'
compile 'com.squareup.picasso:picasso:2.5.2'

compile project(':jwplayer-android-sdk-2.4.2+159')

}

Help would sure be appreciated.

Upvotes: 3

Views: 1709

Answers (3)

Onur Yıldırım
Onur Yıldırım

Reputation: 355

Both answers are about amazon AWS dependency but I had the same issue after putting the exclude command on all of the amazon dependencies. The problem was within another dependency I've been using. To solve the issue, I have put this command on Android Studio terminal:

gradlew app:dependencies

After that, I looked into all of the dependency hierarchies and found ones which included the commons-io. I put the same exclude module command on all of them and the issue was solved.

Upvotes: 2

AndyBeck
AndyBeck

Reputation: 41

If using Android Studio 3.0 this should be:

implementation('com.amazonaws:aws-android-sdk-s3:2.4.0') {
    exclude module: 'commons-io'
}

Upvotes: 1

Alex
Alex

Reputation: 502

Replacing

compile 'com.amazonaws:aws-android-sdk-s3:2.4.0'

with

compile ('com.amazonaws:aws-android-sdk-s3:2.4.0') {
    exclude module: 'commons-io'
}

worked for me. Cheers!

Upvotes: 2

Related Questions