Published on

Configure ant for Android projects

Authors

There are 3 config files generated by android update project or android update-lib-project.

local.properties

lucas-mac:apf-framework lucas$ cat local.properties
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.

# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=/Users/lucas/dev/android/android-sdk-macosx

ant.properties

The ant.properties file can be created by you. It is only edited by the 'android' tool to add properties to it. This is the place to change some Ant specific build properties. Here are some properties you may want to change/update:

  • source.dir
    The name of the source directory. Default is 'src'.

  • out.dir
    The name of the output directory. Default is 'bin'.

For other overridable properties, look at the beginning of the rules files in the SDK, at tools/ant/build.xml.

Properties related to the SDK location or the project target should be updated using the 'android' tool with the 'update' action.

This file is an integral part of the build system for your application and should be checked into Version Control Systems.

project.properties

lucas-mac:apf-framework lucas$ cat project.properties
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-14
android.library=true

Default build.xml generated by android tool

lucas-ma:apf-framework lucas$ cat build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="apf-framework" default="help">

    <property file="local.properties" />

    <property file="ant.properties" />

    <property environment="env" />
    <condition property="sdk.dir" value="${env.ANDROID_HOME}">
        <isset property="env.ANDROID_HOME" />
    </condition>

    <loadproperties srcFile="project.properties" />

    <fail
            message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
            unless="sdk.dir"
    />

    <import file="custom_rules.xml" optional="true" />

    <import file="${sdk.dir}/tools/ant/build.xml" />

</project>