简体   繁体   English

Android库项目自定义构建

[英]Android library projects custom builds

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. 我不使用Eclipse进行开发,也不使用Android SDK提供(生成)的Ant构建(有几个原因:不同的项目目录结构,集成到构建中的单元测试,与CruiseControl的集成,自动构建编号等),但请使用我们的自定义构建文件。

I need to modify my Ant builds to make them build my applications projects that refer my library project. 我需要修改我的Ant构建,以使它们构建引用我的库项目的应用程序项目。 I looked into sample application and Ant builds shipped with SDK, but didn't understand how it is done. 我查看了SDK附带的示例应用程序和Ant构建,但不明白它是如何完成的。 I saw that library project contains "libs" directory and "default.properties" file with "android.library" property set to "true". 我看到该库项目包含“libs”目录和“default.properties”文件,其中“android.library”属性设置为“true”。 I saw that applications project contains "default.properties" file with "android.library.reference.X" property set to library project directory value. 我看到应用程序项目包含“default.properties”文件,其中“android.library.reference.X”属性设置为库项目目录值。 But I didn't find any reference to these properties in the Ant builds (project Ant build file, and Ant builds shipped with SDK). 但是我没有在Ant构建中找到任何对这些属性的引用(项目Ant构建文件,以及随SDK一起提供的Ant构建)。 Just placing these files into application/library project directories doesn't help, ie SDK tools doesn't interpret them. 只是将这些文件放入应用程序/库项目目录中没有用,即SDK工具不会解释它们。

My guess is that this is performed by com.android.ant.SetupTask, but I'd like to know how it is performed. 我的猜测是这是由com.android.ant.SetupTask执行的,但我想知道它是如何执行的。 My build is set of targets that call (using exec) Android SDK tools: appt, dx, apkbuilder and so on. 我的构建是一组调用(使用exec)Android SDK工具的目标:appt,dx,apkbuilder等。 So I'd like to know which command line parameters I need to use to make, lets say, appt tool to merge resources? 所以我想知道我需要使用哪些命令行参数,比方说appt工具来合并资源?

Thank you in advance. 先感谢您。

I recently wrote ant build script for my one of android product that make use of another android framework as library. 我最近为我的一个android产品编写了ant build脚本,它使用另一个android框架作为库。 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. 我使用的技巧是将库项目的src,资源资产复制到主项目中,然后使用ant android任务来构建apk包。 The trick works perfectly for me. 这个技巧对我很有用。

Let me know if you still need some help. 如果您仍需要帮助,请告诉我。

Integrate drive:[path to android sdk]\\tools\\ant\\ant_rules_r3.xml to your build.xml. 将驱动:[android sdk的路径] \\ tools \\ ant \\ ant_rules_r3.xml集成到build.xml中。 It should take care of the copying of the library files and generate the build properly. 它应该负责复制库文件并正确生成构建。

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

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