apkbuilder添加powermock在Android测试项目时,发现重复文件 [英] apkbuilder finds duplicate file when adding powermock to an android test project

查看:1334
本文介绍了apkbuilder添加powermock在Android测试项目时,发现重复文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试添加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:

  1. 请的备份副本 powermock-的Mockito-1.5-full.jar
  2. 重命名 powermock-的Mockito-1.5-full.jar powermock-mockito-1.5-full.zip
  3. 解压缩 powermock-mockito-1.5-full.zip
  4. 的rm -rf的Mockito-扩展
  5. 罐CF powermock-的Mockito-1.5-full.jar META-INF /组织/
  6. 将更新的罐子libs文件夹中。
  1. Make backup copy of powermock-mockito-1.5-full.jar
  2. Rename powermock-mockito-1.5-full.jar to powermock-mockito-1.5-full.zip
  3. Unzip powermock-mockito-1.5-full.zip
  4. rm -rf mockito-extensions
  5. jar cf powermock-mockito-1.5-full.jar META-INF/ org/
  6. Put the updated jar in the libs folder.

这篇关于apkbuilder添加powermock在Android测试项目时,发现重复文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆