0

Our project compiles, but I can't install it into simulator. I see other people reporting similar issues, but their solutions were to change the version number. For us, this works on other developer's machines but not mine. Is there some cache I should delete?

I have reinstalled Android Studio 3.0, deleted ~/.gradle, deleted .gradle folder inside project, restarted AS, clean folder...

Is there something specific about this being an Apache class that is the issue?

Information:Gradle tasks [:app:assembleXXX]
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lorg/apache/commons/io/FileCleaner;
Error:com.android.dex.DexException: Multiple dex files define Lorg/apache/commons/io/FileCleaner;
Error:  at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
Error:  at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
Error:  at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
Error:  at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
Error:  at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
Error:  at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
Error:  at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
Error:  at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
Error:  at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
Error:  at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
Error:  at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
Error:  at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error:Execution failed for task ':app:transformDexArchiveWithDexMergerForXXX'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lorg/apache/commons/io/FileCleaner;

And here is the dependencies from gradle:

dependencies {
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.google.android.gms:play-services-analytics:11.2.0'
implementation 'com.google.android.gms:play-services-gcm:11.2.0'
implementation 'com.google.android.gms:play-services-location:11.2.0'
implementation 'com.google.android.gms:play-services-maps:11.2.0'
implementation 'com.googlecode.android-query:android-query:0.25.9'
implementation 'org.apache.commons:commons-io:1.3.2'
implementation 'org.jsoup:jsoup:1.8.1'
implementation 'com.android.support:appcompat-v7:26.0.1'
implementation 'com.android.support:cardview-v7:26.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.0.1'
implementation 'com.android.support:recyclerview-v7:26.0.1'
implementation 'com.android.support:support-v4:26.0.1'
implementation 'com.android.support:support-v13:26.0.1'
implementation 'de.hdodenhof:circleimageview:2.0.0'
implementation 'io.reactivex:rxandroid:1.1.0'
implementation 'io.reactivex:rxjava:1.1.8'
implementation 'org.altbeacon:android-beacon-library:2.12.1'

}

Jason Hocker
  • 6,879
  • 9
  • 46
  • 79
  • Your project has two copies of Apache Commons IO, in some form where Gradle is not detecting the duplication. You may want to edit the question and post your module's `build.gradle` file, or at least its `dependencies` closure, showing where and how you are declaring the dependency on Commons IO. – CommonsWare Aug 31 '17 at 20:28
  • still a problem on Android Studio 3.0 beta 4 – Jason Hocker Sep 05 '17 at 13:55
  • Somebody may have packaged some of Commons IO in their own library, rather than using a transitive dependency. What you might consider doing is taking this `dependencies` roster, pasting it into some scrap empty project, and doing a build. If you get the same error, then start commenting out dependencies until the error goes away. – CommonsWare Sep 05 '17 at 13:59

2 Answers2

2

I've not been able to find the cause of this problem because non of my dependencies dependes on commons-io, but in my case I fixed it by using another commons-io module:

I replaced
compile 'org.apache.commons:commons-io:1.3.2'

with
compile 'commons-io:commons-io:2.5'

miracula
  • 527
  • 7
  • 10
0

Still not sure on the real answer, but our project works for the people that went to Android Studio 3 beta 3, and then rolled back to beta 2. Myself who never had beta 3 is the one that is broken. We tried this on a other laptops and are confident that something in our project is broken for users on beta 2 who never had beta 3. Our solution will be to wait for the next Android Studio version.

Jason Hocker
  • 6,879
  • 9
  • 46
  • 79