I'm attempting to add powermock-mockito and mockito into an Android Test project. I created the android test project using the android command-line tool to create the build.xml and project structure. I have the following jars in my libs/ directory:
When I attempt to build the project with ant debug, I get the following error:
[apkbuilder] Creating ProjectTests-debug-unaligned.apk and signing it with a debug key...
[apkbuilder] Found duplicate file for APK: mockito-extensions/org.mockito.plugins.MockMaker
[apkbuilder] Origin 1: /home/cmiller/Projects/android-project/ProjectTests/libs/powermock-mockito-1.5-full.jar
[apkbuilder] Origin 2: /home/cmiller/Projects/android-project/ProjectTests/libs/powermock-mockito-1.5-full.jar
BUILD FAILED
/home/cmiller/Applications/adt-bundle-linux/sdk/tools/ant/build.xml:951: The following error occurred while executing this line:
/home/cmiller/Applications/adt-bundle-linux/sdk/tools/ant/build.xml:962: The following error occurred while executing this line:
/home/cmiller/Applications/adt-bundle-linux/sdk/tools/ant/build.xml:319: com.android.sdklib.build.DuplicateFileException: Duplicate files at the same path inside the APK
I'm not sure how it's finding a duplicate file in a single jar. The build.xml file hasn't been modified at all and I haven't created a custom_rules.xml. Any help would be greatly appreciated.
Just remove the duplicate class org.mockito.plugins.MockMaker
from one of the jars. I solved this by doing the following:
powermock-mockito-1.5-full.jar
powermock-mockito-1.5-full.jar
to powermock-mockito-1.5-full.zip
powermock-mockito-1.5-full.zip
rm -rf mockito-extensions
jar cf powermock-mockito-1.5-full.jar META-INF/ org/
Have you checked if the file really is duplicated in the jar file? Afaik it is possible to have the same file twice in a zip file. In that file removing that from the jar could help. No idea how it would get there though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With