Ant use
Apache-ant-1.8.2 package after download in ant's official http://ant.apache.org
Decompress (the storage path should not contain Chinese characters)
Set Lib in ant to environment variable: e: \ Android \ apache-ant-1.8.2 \ Lib
In this way, ant can be directly used in the command line.
Learning materials:
1. ant.rar
2. Documentation: ant tasks à list of tasks under Apache-ant-1.8.2/docs/manual/index.html
Ant's for Loop
There are no related for loop tasks in the ant core package. Someone has already written the corresponding extension package to download.
Extension package: the ant-contrib package is an extension package containing a for loop.
: Http://ant-contrib.sourceforge.net/
Introduction to using the For Loop in this extension package: http://enjoyyou.blog.hexun.com/41449457_d.html
Copy the Lib package in ant-contrib to Apache-ant-1.8.2 \ Lib.
Obfuscation proguard
Obfuscation proguard is an open-source project. Ant automatically uses this open-source project for packaging. There is a proguard folder under the Android-SDK-Windows \ tools directory, the corresponding jar package exists.
There is a bug in the proguard jar package that comes with the android SDK. When obfuscation occurs in some methods, an exception is reported. To solve this bug, you only need to go to the proguard official website http://proguard.sourceforge.net/download the latest jarpackage progu
After downloading the SDK, replace the jar package in Android-SDK-Windows \ tools \ proguard \ Lib with the jar package in proguard4.6 \ Lib \ bin. replace the file ending with bat with the file in Android-SDK-Windows \ tools \ proguard \ bin.
Download the project (svnant) in SVN)
Because our project is managed with SVN, so we need to use ant to download the latest code, according to the server svnservice version to svnant official website http://subclipse.tigris.org/svnant.html to download svnant version, I used: svnant-1.1.0-RC2
Then just copy the jar package in svnant-1.1.0-RC2 \ Lib to Apache-ant-1.8.2 \ Lib.
The downloaded jar contains the corresponding DOC file, so you can know how to use it.
Write scripts to deploy Projects
- Add several files (build. properties, build. XML, local. properties, proguard. CFG), how to get these files, you just need to create an android project with commands to get these files (these files are basically the same for different projects ):
Now let's talk about these files:
1 ). build. XML file: this file is the ant runtime script, which is a fixed template and needs to be changed mainly: <project name = "myandroidapp" default = "help"> scripts ); but note that this file should not be opened in eclipse. If it is opened, an error will be reported. The solution is to delete the file first and then copy it in.
2). Build. properties file: This is an attribute file that can be used to change some attributes during compilation. I mainly use the following attributes:
Jar. libs. dir indicates that if you reference the path of a third-party jar package, its default = libs
Java. Encoding indicates the file encoding. Its default value is GBK.
Key. Store indicates the Key Path, for example, XX/xxxx. keystore.
Key. Alias indicates the key alias. This alias does not contain paths.
Key. Store. Password, key. Alias. Password is not required.
3). Local. properties file: this is also an attribute file, which is used to record the path of SDK. dir
4). proguard. cfg file: This is a mixed configuration file, most of which are the same, as long as you follow the template, which focuses on two points:
*. -Keep class * extends android. view. view indicates that custom view objects are not obfuscated. By default, they do not exist, but this must be written because the full path is used in the XML file.
*. -Dontwarn COM. mapbar. android. ** this is very important. If we use a third-party jar package, the third-party jar package will be obfuscated during compilation, if the jar package of the third method has a class associated with the class not added to this jar package, it will be warn during compilation, and this warn will terminate the compilation process. In this sentence, do not throw the warn prefix com. mapbar. Android so that the compilation process will not be terminated.
-
Write ant scripts and configuration files (build. XML, build. properties)
A). Build. properties is an attribute file, which is a package configuration file.
B) write the. Build. xml file:
-
Use: you only need to open the command line to enter this directory, and an ant command will do.
Ant automatic Packaging