Android 库项目自定义构建 [英] Android library projects custom builds

查看:34
本文介绍了Android 库项目自定义构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个遗留应用程序,需要将其拆分为一个库项目(公共代码)和两个应用程序项目(付费和免费应用程序).我不使用 Eclipse 进行开发,也不使用 Android SDK 提供(生成)的 Ant 构建(有几个原因:不同的项目目录结构、集成到构建中的单元测试、与 CruiseControl 的集成、自动构建编号等),但请改用我们的自定义构建文件.

I have a legacy application and need to split it into a library project (common code) and two application projects (paid and free applications). I don't use Eclipse for development, and also don't use Ant builds provided (generated) by Android SDK (there are several reasons for that: different project directory structure, unit tests integrated into the build, integration with CruiseControl, automatic builds numbering etc), but use our custom build files instead.

我需要修改我的 Ant 构建,以使它们构建引用我的库项目的应用程序项目.我查看了 SDK 附带的示例应用程序和 Ant 构建,但不明白它是如何完成的.我看到库项目包含libs"目录和将android.library"属性设置为true"的default.properties"文件.我看到应用程序项目包含default.properties"文件,android.library.reference.X"属性设置为库项目目录值.但是我没有在 Ant 构建(项目 Ant 构建文件和 SDK 附带的 Ant 构建)中找到对这些属性的任何引用.仅将这些文件放入应用程序/库项目目录并没有帮助,即 SDK 工具不会解释它们.

I need to modify my Ant builds to make them build my applications projects that refer my library project. I looked into sample application and Ant builds shipped with SDK, but didn't understand how it is done. I saw that library project contains "libs" directory and "default.properties" file with "android.library" property set to "true". I saw that applications project contains "default.properties" file with "android.library.reference.X" property set to library project directory value. But I didn't find any reference to these properties in the Ant builds (project Ant build file, and Ant builds shipped with SDK). Just placing these files into application/library project directories doesn't help, i.e. SDK tools doesn't interpret them.

我猜这是由 com.android.ant.SetupTask 执行的,但我想知道它是如何执行的.我的构建是一组调用(使用 exec)Android SDK 工具的目标:appt、dx、apkbuilder 等.所以我想知道我需要使用哪些命令行参数来制作合并资源的 appt 工具?

My guess is that this is performed by com.android.ant.SetupTask, but I'd like to know how it is performed. My build is set of targets that call (using exec) Android SDK tools: appt, dx, apkbuilder and so on. So I'd like to know which command line parameters I need to use to make, lets say, appt tool to merge resources?

提前致谢.

推荐答案

我最近为我的一个 android 产品编写了 ant 构建脚本,该脚本使用另一个 android 框架作为库.我使用的技巧是将库项目的src,resourceassets 复制到主项目中,然后使用ant android task 构建apk 包.这个技巧非常适合我.

I recently wrote ant build script for my one of android product that make use of another android framework as library. The trick I used was to copy src,resource and assets of library project into the main project and then use ant android task to build the apk package. The trick works perfectly for me.

如果您还需要帮助,请告诉我.

Let me know if you still need some help.

这篇关于Android 库项目自定义构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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