2

When trying to include EasyMock in my Android project, I get the following error when running my tests. Which is trying to package up the same jar twice.

Execution failed for task ':Example:packageDebugTest'.
> Duplicate files copied in APK META-INF/INDEX.LIST
    File 1: /home/me/.gradle/caches/modules-2/files-2.1/org.easymock/easymock/3.2/c82f7fa3ef377d8954b1db25123944b5af2ba4/easymock-3.2.jar
    File 2: /home/me/.gradle/caches/modules-2/files-2.1/org.easymock/easymock/3.2/c82f7fa3ef377d8954b1db25123944b5af2ba4/easymock-3.2.jar

My build.gradle looks like:

android {
...
packagingOptions {
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/license.txt'
}
...
}

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    instrumentTestCompile 'junit:junit:3.8.2+'
    instrumentTestCompile('org.easymock:easymock:3.2'){
        exclude group: 'junit', module: 'junit'
    }
}

And I don't feel it is a good idea to exclude INDEX.LIST I guess even if I did that, I'd get duplicates for every file in the jar.

Why is it trying to add EasyMock twice? How can I stop it from doing this?

NB - Android environments:

  • Android-Studio version 0.4.0

  • Android Gradle Plugin version 0.7.1

  • Gradle version 1.9

twlkyao
  • 14,302
  • 7
  • 27
  • 44
yarbelk
  • 7,215
  • 6
  • 29
  • 37
  • 1
    It's weird that it adds easyMock twice. I'll look into it. I created a bug to track this: http://code.google.com/p/android/issues/detail?id=64279 – Xavier Ducrohet Dec 31 '13 at 07:04
  • While solving such error always take care of what told in http://stackoverflow.com/a/30935051/4773561 !!! – Shreekant N Jun 20 '15 at 08:25
  • While solving such error always take care of what told in http://stackoverflow.com/a/30935051/4773561 !!! – Shreekant N Jun 20 '15 at 08:27

1 Answers1

0

As a work around I did the following, which gets my tests to build

Manually add:

  • cglib-nodeps-2.2.2.jar
  • dexmaker-1.0.jar
  • dexmaker-dx-1.0.jar
  • easymock-3.2.jar
  • junit-3.8.2.jar

to test_libs dir,

and add the following to build.gradle:

dependencies {
...
    instrumentTestCompile fileTree(dir: 'test_libs', include: '*.jar')
...
}

Everything compiles fine and the tests run:

I also had to do the following: dexmaker-issue2 to fix the no dex cache issue.

yarbelk
  • 7,215
  • 6
  • 29
  • 37