Ant Introduction
Ant is a command-line tool written in the Java language, and the main task is to complete the target in the build file. The main thing we know is to build Java applications, and of course it can also be used to build C + + programs.
Installation and use
: http://ant.apache.org/bindownload.cgi, unzip the downloaded package to the appropriate directory, my directory is: D:\apache-ant-1.9.4
Adding environment variables
Add Ant_home: Point to the directory where Ant is located, for example: D:\apache-ant-1.9.4, and then include the bin directory in path:%ant_home%\bin
Test installation
Open the command line, enter Ant, and the following prompt indicates that the installation was successful:
Buildfile:build.xml does not exist! Build failed
apply to Android projects
have been using Eclipse to develop Android projects, the test is directly installed on the phone with Eclipse run, in fact, the principle is that eclipse comes with ant Tools, Android by default using ant to compile, package, install. Next, let's take a look at the process of packaging Android projects with the command line.
In Android, the default is to use ant to compile, packaged (and now use Gradle), in the SDK directory can find the ant build file, the path is: <sdk path>\tools\ant\ Build.xml, this build.xml file contains all the information that Android needs for Target. So we can compile, package, and install the Android project on the command line.
1. Configure the JDK environment variables first, add Java_home,c:\program files\java\jdk1.7.0_09
2. Before you package the project, you need to make a build.xml file, placed under the project's root directory. Don't worry, Android also provides us with the tools, Android.bat, under the Tools directory of the SDK, in order to use the SDK's tools directory can be added to the environment variables. Now we can open cmd and switch the directory to the root of the project that needs to build, such as one of my projects: Ant_test, in D:\workspace1\ant_test, and then execute the command:
Android Update project-p. -T 12, where-p represents the directory for project;-T is the build target
To view the sequence number of the build target you can execute the command:
Android list target
3. The build,xml,local.properties file is generated under the Ant_test root directory, where local.properties is the directory of the Android SDK and <SDK path is imported at the end of the Build.xml file. Build.xml in the >\tools\ant\ directory. In general, we also need to manually create a ant.properties file to add related configurations, such as signature-related information.
4. Finally, the Ant_test project can be manipulated with the ant command, such as the first Ant Clean,clean Project, the second, ant Debug, the package that tests the project, and then the corresponding apk in the project's Bin directory.
Note: If your project relies on another library, you will need to generate the appropriate Build.xml file for the library first.
The Ant Android Project uses a detailed