AntIs a Java-based build tool, similar to make in (UNIX) C. Unlike the extension mode based on shell commands, ant extends with Java classes, you do not have to write shell commands. Ant is a process script engine used to automatically call programs to compile, package, and test projects. In addition to Java, the script format is based on XML (default: Build. XML), which is easier to maintain than make scripts.
1. Download
Official download: ant
Download: apache-ant-1.9.0-bin.tar.gz
2. Install
1) decompress
Tar zxvf apache-ant-1.9.0-bin.tar.gz
2) configure the environment
Sudo VI/etc/profile
Export ant_home =/home/Homer/Apache-Maven/ant-1.9.0/
Export Path = $ ant_home/bin: $ path
Sudo source/etc/profile
3) Verification
Homer @ Ubuntu :~ $ Ant-V
Apache ant (TM) version 1.9.0 compiled on March 5 2013
Trying the default Build File: Build. xml
Buildfile: Build. XML does not exist!
Build failed
Installation complete!
4. Create a project
1) List Android platforms
Android list targets
The output result is as follows:
2) create a project using the android command
Command Format:
Android Create project -- target <target-ID> -- name myfirstapp -- path <path-to-workspace> myfirstapp -- activity mainactivity -- package com. example. myfirstapp
The command for creating anttest is as follows:
Android Create project -- target Android-3 -- name anttest -- path/home/Homer/workspace/anttest -- activity mainactivity -- package com. Homer. anttest
Create a project as follows:
5. compile the project
1) enter the project directory
CD/home/Homer/workspace/anttest
2) check whether the build. xml file exists.
The build. xml file is used as the ant configuration file under the root directory of the project. If no, it is generated through Android update. The command is as follows:
Android update project -- target Android-3 -- name anttest -- path/home/Homer/workspace/anttest
3) compile the project with the ant command
In the project anttest root directory, enter the compilation command:
Ant debug
The output command information is as follows:
At this point, the bin directory will generate a AntTest-debug.apk and other files, such:
6. Installation Verification
1) List AVD
Android list AVD
The AVD list is as follows:
2) Start the simulator
Android-SDK-Linux/tools/emulator-AVD AVD-1.5
3) install APK
ADB install bin/AntTest-debug.apk
Reference recommendations:
Create a project for Android (Wikipedia)
Ant: Create and compile an android Project
Android command line generation and running projects