Android Custom Build Using Ant

These 4 files (build.xml, local.properties, projects.properties, proguard.cfg) are automatically generated at startup:

Android update project - name TestApp --target 10 -p.

Updated project.properties

Updated by local.properties

Added file. /build.xml

Updated file. /proguard.cfg

But I want the "auto-gen" build.xml to also include the following "pre-compile" code, is there any way to do this? Is there any “include” or “template” file that might include this?

<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> 
+10
android build ant
Dec 16 2018-11-11T00:
source share
3 answers

build.xml created by the android tool (at least when using the Android SDK r20) contains this piece of code:

 <!-- 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" /> 

So, what am I doing to create additional goals or to configure existing goals, I need to create a custom_rules.xml file with these new goals. Please note that in my tests, the targets should be nested in the <project> , so just copy the first two lines of your generated build.xml to custom_rules.xml and don't forget to close the </project> at the end. Since custom_rules.xml will not be overwritten by android update , your changes will be permanent and can be checked in the SCM tool of your choice.

+13
Sep 04 '12 at 8:11
source share

Perhaps you can check the answer to this question:

ADT plugin automatically creates ant build file?

the answer has a paragraph saying ...

Alternatively, you can simply copy the build.xml template directly from $ ANDROID_HOME / tools / lib / build.template, and then simply change the name of the project.

Modify this file and run the commands to see if it works.

Update

Also check out the "Build Customization" section of this article: http://www.androidengineer.com/2010/06/using-ant-to-automate-building-android.html

+3
Dec 20 2018-11-11T00:
source share

In build.xml , it tells you how to do this. See the following comment from the file:

 <!-- *********************** ****** IMPORTANT ****** *********************** In all cases you must update the value of version-tag below to read 'custom' instead of an integer, in order to avoid having your file be overridden by tools such as "android update project" --> <!-- version-tag: 1 --> 
+1
Feb 17 '12 at 16:05
source share



All Articles