Prerequisites: jdk + ant1.8 + android-sdk must be installed first.
1. In the \ android-sdk \ tools directory.
Android. bat list targets
This command can list the IDs used for the following-t parameters.
Create a project:
Android create project-k com. android. Tank-a Tank-t 1-p E: \ workspace \ tank
Update Project:
Android update project -- name Tank-t 1-p F: \ tank
Projects that have been processed with the preceding commands will automatically include the build. xml file. The actual files are: android-sdk \ tools \ ant \ build. xml
Next, start the custom compilation process. It involves four files in the project root directory:
Ant. properties
Build. xml
Custom_rules.xml
Local. properties
2. Signature file and Configuration
First make a signature file yourkey.
In the ant. properties file, add the following content:
Key. store = yourkey
Key. store. password = password
Key. alias = alias
Key. alias. password = password
Note: alias can be Chinese. Transcode to \ u5a74 format. Otherwise, it cannot be recognized.
3. local. properties
Sdk. dir = D :\\ android \ Android \ android-sdk
Explicitly set your android-sdk directory. The setting of ANDROID_HOME is read by default.
4. build. xml
You only need to modify <project name = "yourname" to your desired name. The prepared result is yourname-release.apk, which is in the bin directory.
5. custom_rules.xml
This file has been referenced in build. xml. You can customize the content of the following nodes:
-Pre-build
-Pre-compile
-Post-compile
-Post-package
-Post-build
-Pre-clean
When you look at the name, you will know that it corresponds to different phases of compilation. You can add some features. For example, during pre-build, modify the version to support automatic update. In per-build, publish the result apk to the desired directory. And so on.
In general, it is easy to compile android projects.
This compilation file only supports compiling a single source code directory. The default value is src. If the project contains multiple source code directories, you need to merge multiple directories into src in pre-compile.