简体   繁体   English

使用Ant构建Android库项目

[英]Build Android Library Project With Ant

I am having trouble building my Android library project with ant. 我在使用ant构建Android库项目时遇到问题。 When I try to run ant release , it says Target "release" does not exist in the project "MyProject" . 当我尝试运行ant release ,它表示Target "release" does not exist in the project "MyProject"

I then assumed that perhaps libraries do not get build with release/debug, so I started using ant compile , which seems to work. 然后我假设可能库没有使用发布/调试进行构建,所以我开始使用ant compile ,这似乎有效。 I then zip the folder manually using java's zip utility and rename it to .apk. 然后我使用java的zip实用程序手动压缩文件夹并将其重命名为.apk。 I am guessing this is the wrong way to do this. 我猜这是做错的方法。

Can anyone show me how to build an Android library project using ant? 谁能告诉我如何使用ant构建Android库项目?

I then assumed that perhaps libraries do not get build with release/debug 然后我假设可能库没有通过发布/调试进行构建

Correct. 正确。

I am guessing this is the wrong way to do this. 我猜这是做错的方法。

Also correct. 也正确。

Can anyone show me how to build an Android library project using ant? 谁能告诉我如何使用ant构建Android库项目?

You typically do not build an Android library project. 您通常不构建Android库项目。 You build other projects that reference the Android library project. 您构建了引用Android库项目的其他项目。 Creating projects that reference the library project, for use with Ant, is covered in the Android documentation . Android文档中介绍了创建引用库项目的项目,以便与Ant一起使用。 More information about the role of Android library projects can also be found in the Android documentation . 有关Android库项目角色的更多信息也可以在Android文档中找到。

I had the same trouble with a target "nodeps" that was not known by Ant when building a project that was referencing a library. 在构建引用库的项目时,我对Ant不知道的目标“nodeps”也遇到了同样的问题。 I added a fake target "nodeps", then I get the target "release" unknown. 我添加了一个假目标“nodeps”,然后我得到目标“释放”未知。 Wrong way. 错误的方法。

Solution : in my referenced library directory, I run the command android update project -p . 解决方案:在我引用的库目录中,运行命令android update project -p . that created the build.xml compatible with Ant build. 创建了与Ant构建兼容的build.xml。

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

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