Getting started with Apache ant

Source: Internet
Author: User
Tags windows download

Background:

Android development has been done for some time, but it is found that the package of the items in normal times always needs to be done manually, and the version and file check should be carried out repeatedly, Which is troublesome for the program, it is easy to cause negligence ...... According to the investigation, we found that android can use ant to quickly compile, package, and sign a series of tasks... So I started to study the API doc in recent days. Now I will record my research experiences ~

Content:

Android develop tools doc -- building and running from the command line use the ant tool to compile and package the signature for publishing.

There are two ways to build Android: In debug mode & in release mode.

In debug mode: you only need to use DEBUG keystore to compile the APK with a signature and zipalign.

In release mode: first, an unsigned APK is compiled, and then sign and zipalign work are executed to obtain the available APK.

PS: to publish an APK, it must be release version.


The following describes how to download, install, and use ant:

Download ):

First go to Apache ant home page: http://ant.apache.org/index.html. Here, there are two versions of ant available for download using Source & Bin difference

Windows download .zip UNIX/linuxdownload .tar.gz

The latest version may 23,201 2-Apache ant 1.8.4 released: Download source; download Bin

After the download is complete, check [PGP]
[Sha1] [sha512]
[MD5]
[MD5] is verified here.

PS: PGP verification, is the most recommended, but download gpnup software seems a bit troublesome, the address is http://www.gnupg.org/download/

The download of ant and Pgp involves the concept of a mirror network address. This is an image address: Simply put, they all have an original server, because of globalization, therefore, it is impossible for everyone to access this original server. Therefore, they generally deploy indirect servers that can be accessed by users in major countries in various regions, this indirect server is the mirror server, and the corresponding address is the mirror site. When downloading, you only need to find the nearby
Mirror site.


Ant.zip package directory structure:

The binary distribution of ant consists of the following directory layout:

  ant   +--- README, LICENSE, fetch.xml, other text files. //basic information   +--- bin  // contains launcher scripts   |   +--- lib  // contains Ant jars plus necessary dependencies   |   +--- docs // contains documentation   |      |   |      +--- images  // various logos for html documentation   |      |   |      +--- manual  // Ant documentation (a must read     |   +--- etc // contains xsl goodies to:            //   - create an enhanced report from xml output of various tasks.            //   - migrate your build files and get rid of 'deprecated' warning            //   - ... and more  

If run ant, only bin \ & Lib \ required.

Install: PS ant is a tool. Therefore, Bin edition is generally downloaded.Apache-ant-1.8.4-bin.zip; After the download is complete

1. Verify [MD5],
Start with win7, enter MD5 in the search box, and an MD5 validator will be available;

2. Decompress apache-ant-1.8.4-bin.zip to intall_dir; (Note the contents in the directory). decompress the path intall_dir = G: \ apache-ant-1.8.4-bin \ apache-ant-1.8.4.

3. Set JDK environment variables java_home and ant environment variables ant_home; do not set calsspath. If this parameter is set, problems may occur.

Computer properties-advanced-environment variable: User variable -- New, variable name = ant_homevariable value = G: \ apache-ant-1.8.4-bin \ apache-ant-1.8.4 system variable path open, append; G: \ apache-ant-1.8.4-bin \ apache-ant-1.8.4 \ bin or % ant_home % \ bin, but my computer does not use % \ bin; I don't know why?

Check installation:

Run CMD and enter ant. Output: buildfile: Build. XML does not exist! Build failed indicates that the installation is successful. Otherwise, the system prompts that ant is not an 'internal' or 'external' command. If it fails, first check whether your environment variables are correctly set.

Meaning of the variables:

Ant_home is used by the launcher script for finding the libraries. java_home is used by the launcher for finding the JDK/JRE to use. (JDK is recommended as some tasks require the Java tools .) if not set, the launcher tries to find one via the % PATH % environment variable. PATH is set for userconvinience. with that set you can just start ant instead of always typing the/complete/path/to/Your/ANT/Inst We strongly recommend that you install JDK in allation/bin/ant.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.