Android的命令行工具 - 蚂蚁调试项目使用库 [英] Android Command Line Tool - Ant Debug in project with libraries
问题描述
我创建了一个测试项目,以了解如何构建和运行使用命令行工具测试。我设法创建一个项目,它更新
I created a test project to understand how to build and run the tests using command line tool. I managed to create a project, updated it with
android update project -p .
和调试
ant debug
当我添加一个库项目,这个测试项目,蚂蚁调试开始失败,因为它找不到库的build.xml文件。我发现ATM唯一的解决办法是更新库项目以及(<一个href=\"http://stackoverflow.com/questions/13929734/build-and-run-android-project-having-a-subproject-in-command-line-using-ant-debu\">found这里)。这是正确的方法是什么?我看到很多,我使用的库的pom.xml文件。我知道它是由Maven的使用(虽然我什么都不知道),它可以帮助我和其他的解决方案。
When I added a library project to this test project, the ant debug started to fail because it couldn't find the build.xml of the library. The only solution I found atm is to update the library project as well (found here). Is this the correct way? I see pom.xml files in many of the libraries that I use. I know it is used by Maven (although I know nothing about it) and it might help me with another solution.
推荐答案
蚂蚁是的官方的方式来构建Android APK。 Maven是这样做的另一种方式(不正式支持,但它工作得很好)。
Ant is the official way to build android apk. Maven is an alternative way of doing it (not officially supported, but it works very well).
有关于默认项目布局与Maven或蚂蚁工作时数的差别,但它可能有两个构建系统相同的源$ C $ C的工作,如果你做一些其它附加的配置工作(即一些信息会被复制)
There are few differences regarding default project layout when working with maven or ant, but it's possible to have both build system working on the same source code if you do some additionnal configuration work (i.e. some information will be duplicated).
默认项目布局与Maven
- Java源文件在`/ src目录/主/ java``
- 相关性在pom.xml定义(使用定义的依赖关系,与类型的Maven的方式
apklib
为Android库)
- java source files are under `/src/main/java``
- dependencies are defined in the pom.xml (using the maven way of defining dependencies, with type
apklib
for android libraries)
默认项目布局与蚂蚁(和eclipse ADT插件)
- Java源文件在
/ src目录
- 的依赖在
/project.properties
定义和使用相对路径来指定。
- java source files are under
/src
- dependencies are defined in
/project.properties
and are specified using relative path.
下面是 project.properties
的一个实例(它是一个库项目引用其他2库项目的典型例子):
Here is an example of project.properties
(it's a typical example of a library project referencing 2 other library project):
target=android-15
android.library=true
android.library.reference.1=../somelib
android.library.reference.2=../someOtherLib
(你可以看到存储在此文件中的一些其它附加信息,:Android的目标,事实上,该项目是一个库或应用程序在使用Maven的,这个信息在pom.xml)
(as you can see some additionnal information are stored in this file : the android target and the fact that the project is an library or an app. When you use maven, this information is in the pom.xml)
如何建立与蚂蚁?一个Maven的Android LIB
该问题(当你需要创建一个 Maven的布局Android的库
与蚂蚁
)是以下内容:
The problems (when you need to build a maven-layout-android-library
with ant
) are the following:
- 有一个适当的
/build.xml
(它可以通过完成Android的更新库项目...
这里是这个命令官方文档) - 有一个适当的
/project.properties
(这部分由Android的更新做...
命令,但是你可能需要一些android.library.reference
用手或用Eclipse的ADT插件)添加 - 告诉
蚂蚁
的Java源文件不在默认位置,但正在/ src目录/主/ JAVA
- having a proper
/build.xml
(it can be done throughandroid update library-project ...
here is the official doc about this command) - having a proper
/project.properties
(it is partially done by theandroid update ...
command, but you may need to add someandroid.library.reference
by hand or with eclipse ADT plugin) - telling
ant
that the java source files aren't at the default location, but are under/src/main/java
有关最后一点,这里是如何做到这一点:
For this last point, here is how to do it:
- 创建一个文件
/ant.properties
(在Maven的布局Android的库
) -
把下面的条目是:
- create a file
/ant.properties
(in yourmaven-layout-android-library
) put the following entry in it:
source.dir =的src / main / JAVA
source.dir=src/main/java
(重要提示:它并不总是必要的,因为有时Java源文件已经在 / src目录
在Maven的布局项目,在这种情况下,pom.xml中包含的源dir是信息 / SRC
)
(Important : it is not always required because sometimes the java source files are already under /src
in the maven-layout-project and in this case, the pom.xml contains the information that the source dir is /src
)
而这一切。现在,你的 Maven的布局Android的库
可以建立与蚂蚁调试
And that's all. Now, your maven-layout-android-library
can be build with ant debug
这篇关于Android的命令行工具 - 蚂蚁调试项目使用库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!