这4个文件(build.xml,local.properties,projects.properties,proguard.cfg)在运行时自动生成:
android update project –name TestApp –target 10 -p .
Updated project.properties
Updated local.properties
Added file ./build.xml
Updated file ./proguard.cfg
但是我想要“auto-gen”build.xml也包含以下“预编译”代码,有没有办法呢?有没有包含“包含”文件或“模板”文件?
<target name="config"> <property name="config-target-path" value="${source.dir}/com/androidengineer/antbuild"/> <!-- Copy the configuration file,replacing tokens in the file. --> <copy file="config/Config.java" todir="${config-target-path}" overwrite="true" encoding="utf-8"> <filterset> <filter token="CONFIG.LOGGING" value="${config.logging}"/> </filterset> </copy> </target>
解决方法
android工具生成的build.xml(至少在使用Android SDK r20时)包含这段代码:
<!-- Import per project custom build rules if present at the root of the project. This is the place to put custom intermediary targets such as: -pre-build -pre-compile -post-compile (This is typically used for code obfuscation. Compiled code location: ${out.classes.absolute.dir} If this is not done in place,override ${out.dex.input.absolute.dir}) -post-package -post-build -pre-clean --> <import file="custom_rules.xml" optional="true" />
那么我做什么来创建额外的目标或自定义现有的目标是创建一个具有这些新目标的custom_rules.xml文件.请注意,在我的测试中,目标需要嵌套在< project>标签,所以只需将生成的build.xml的前两行复制到custom_rules.xml,不要忘记关闭< / project>标签到底.由于custom_rules.xml不会被android更新覆盖,您的更改将会持续存在,并且可以检查您选择的SCM工具.