If you want to automate builds of your Android applications, you will need to generate a build.xml file for your project for use with Ant. While it’s not clear from the Android Dev docs how to do this, it is actually very simple:
$ ANDROID_SDK/tools/android update project -p DIR_OF_PROJECT -n "NAME_OF_APP" -s -t ANDROID_TARGET_ID
Where ANDROID_SDK is the location of your Android SDK installation, DIR_OF_PROJECT is the path to your project folder and NAME_OF_APP is the name of your app. ANDROID_TARGET_ID is the identifier of one of the Android versions you have installed as part of your SDK, but note that the target ID is not the same as the Android version you are targeting. You can view the target IDs for all the installed Android versions using the list command:
$ ANDROID_SDK/tools/android list targets
A successful run generates a build.xml file (and supporting properties files) in your project folder that you can now use to build your APK using:
$ ant release
This creates an unsigned APK that you will still need to sign before releasing but luckily you can also automate that. If you would like to only create a debug build, use ant debug instead.
The full list of options available for android update project are:
-l --library : Directory of an Android library to add, relative to this project's directory. -p --path : The project's directory. [required] -n --name : Project name. -t --target : Target ID to set for the project. -s --subprojects: Also updates any projects in sub-folders, such as test projects.