Ant compilation android Project

Source: Internet
Author: User

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.

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.