我正在尝试将powermock-mockito和mockito添加到Android Test项目中。我使用android命令行工具创建了android测试项目来创建build.xml和项目结构。我的libs /目录中有以下jar:
当我尝试使用ant debug构建项目时,出现以下错误:
[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
我不确定它是如何在一个jar中找到重复文件的。 build.xml文件根本没有被修改过,我还没有创建custom_rules.xml。任何帮助将不胜感激。
答案 0 :(得分:3)
只需从其中一个jar中删除重复的类org.mockito.plugins.MockMaker
即可。我通过以下方式解决了这个问题:
powermock-mockito-1.5-full.jar
powermock-mockito-1.5-full.jar
重命名为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/
答案 1 :(得分:2)
您是否检查过该文件中的文件是否真的重复了? Afaik可以在zip文件中两次使用相同的文件。在该文件中从jar中删除它可能会有所帮助。不知道怎么会到那里。