简体   繁体   English

使用ANT脚本构建Android测试项目

[英]Build Android Test Project using ANT script

I have a Android Project which is running fine on command line as well as using eclipse. 我有一个可以在命令行以及使用Eclipse正常运行的Android项目。 So now I created the test project for the same, currently it is dependant on one external JAR. 因此,现在我为相同的项目创建了测试项目,当前它依赖于一个外部JAR。 I kept this jar in libs/ directory. 我把这个罐子放在libs /目录中。 I can build and run the test project from command line. 我可以从命令行构建和运行测试项目。

Now the problem is that Eclipse is not able to recognize the JAR placed in libs directory and so eclipse is not able to build the project. 现在的问题是,Eclipse无法识别放置在libs目录中的JAR,因此eclipse无法构建项目。 I tried to modify build.properties file (setting the libs path in it), but that does not helped me.I don't want use properties ->JAVA build path -> Libraries -> Add external JARS in eclipse 我试图修改build.properties文件(在其中设置libs路径),但这对我没有帮助。我不想使用properties-> JAVA build path-> Libraries->在eclipse中添加外部JARS

Can some one tell the exact steps to build the test project with command line as well as with eclipse . 有人可以告诉我们使用命令行以及Eclipse构建测试项目的确切步骤。 Also, can I keep the JARs on another location than project directory ? 另外,我可以将JAR保留在项目目录之外的其他位置吗?

I don't want to use Maven 我不想使用Maven

I encounter a similar problem with the following configuration: 我在以下配置中遇到类似的问题:

MainProject
-src
 -...
-libs
  -ok.jar

TestProject
-src
 -testFiles

The ok.jar file is both needed by the MainProject and the TestProject ok.jar文件是MainProject和TestProject都需要的

If I add the jar into TestProject/libs/ok.jar the build fail cause of class duplication. 如果我将jar添加到TestProject / libs / ok.jar中,则会导致类重复的构建失败。 If I reference the MainProject/libs/ok.jar file threw external jar into the properties of the TestProject it does not work either. 如果我引用MainProject / libs / ok.jar文件,将外部jar放入TestProject的属性中,则它也不起作用。

I finally modified the properties of the MainProject to make it export the ok.jar file to other project by checking the combobox: 我最后修改了MainProject的属性,以通过检查组合框将ok.jar文件导出到其他项目:

Project Properties -> Java Build Path -> Order and Export -> check the ok.jar file. 项目属性-> Java构建路径->订单和导出->检查ok.jar文件。

Last, the TestProject reference the MainProject as "Required projects on the build path". 最后,TestProject将MainProject引用为“构建路径上的必需项目”。

Now the test project can see and use the ok.jar file. 现在,测试项目可以查看并使用ok.jar文件。

It works fine threw eclipse and ant. 它的工作原理很好,可以把日食和蚂蚁扔掉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM