问题描述
我尝试添加powermock-的Mockito和的Mockito到Android的测试项目。我创建使用了android命令行工具来创建build.xml文件和项目结构Android的测试项目。我有以下的罐子在我的库/目录:
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:
- dexmaker-1.0.jar
- dexmaker-的Mockito-1.0.jar
- 的Mockito-全1.9.5.jar
- powermock-的Mockito-1.5-full.jar
当我试图建立与蚂蚁调试项目,我得到以下错误:
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
我不知道它是如何找到重复的文件在一个jar。 build.xml文件尚未修改的一切,我没有创建一个custom_rules.xml。任何帮助将大大AP preciated。
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.
推荐答案
刚刚从罐子中的一个删除重复的类 org.mockito.plugins.MockMaker
。我用以下方法解决了这个:
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
到powermock-mockito-1.5-full.zip
- 解压缩
powermock-mockito-1.5-full.zip
-
的rm -rf的Mockito-扩展
-
罐CF powermock-的Mockito-1.5-full.jar META-INF /组织/
- 将更新的罐子libs文件夹中。
- Make backup copy of
powermock-mockito-1.5-full.jar
- Rename
powermock-mockito-1.5-full.jar
topowermock-mockito-1.5-full.zip
- Unzip
powermock-mockito-1.5-full.zip
rm -rf mockito-extensions
jar cf powermock-mockito-1.5-full.jar META-INF/ org/
- Put the updated jar in the libs folder.
这篇关于apkbuilder添加powermock在Android测试项目时,发现重复文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!