Ant package android applications

Source: Internet
Author: User

I. Prepare ant and android

1. Decompress ant and android downloaded from the official website to your local device.
2. Set ANT_HOME and ANDROID_HOME in environment variables, such as: F: \ software \ apache-ant-1.9.3, F: \ android \ adt-bundle-windows-x86-20140321 \ sdk
3. Add % ANT_HOME % \ bin and % ANDROID_HOME % \ bin to path
Note: ANT_HOME and ANDROID_HOME must be configured, because we will use build. xml

2. Add an ant environment for a project (such as the Project name WebView)
Run the doscommand to enter the project root path, for example, cd F: \ workspace_android \ WebView. Run the following command:

Android update project -- name WebView-t 2-p F: \ workspace_android \ WebView
After this command is run, build. xml is added to the project path.

-- Name must be available, followed by the Project name
-P indicates the project path
-T indicates the target version, that is, the target id of android. Run the "android list target" command to view the target id:
Id: 1 or "android-18"
Name: IOS 4.3
...
Id: 2 or "android-19"
...
We can see that id 2 represents the android-19 version.

3. Release a project

You can run the ant release or ant clean release command (recommended). If you do not run the clean command to directly release ant release, the release may fail.

This command will be based on the ant. properties to find the key. If ant is not found. properties to publish an unsigned apk file, but the unsigned apk cannot be installed on the mobile phone.
So we need to create the ant. properties file with the following content:

Key. store = android. keystore
Key. alias = android. keystore
Key. store. password = 123456
Key. alias. password = 123456

This content is for android. if there is no keystore key, we need to create it first. Google recommends that this key be created only once, because data sharing may be required for multiple apps we develop.
The command to generate the keystore is as follows:
Keytool-genkey-alias android. keystore-keyalg RSA-validity 20000-keystore android. keystore

Then, enter the key password and organization information:

Enter the keystore password: 123456
Enter the new password again: 123456
What is your first name and last name?
[Unknown]: zhang biao
What is the name of your organization?
[Unknown]: **
What is your organization name?
[Unknown]: **
What is the name of your city or region?
[Unknown]: shenzhen
What is the name of your province/city/autonomous region?
[Unknown]: guangdong
What is the dual-letter country/region code for this unit?
[Unknown]: CN
CN = zhang biao, OU = aisaw, O = aisaw, L = shenzhen, ST = guangdong, C = CN is correct?
[No]: y
In this way, android. keystore is generated, and you do not need to create it again later. copy the file to the project path.

In this case, if the subscription succeeds, we can see that the binfile of the project contains webview_release.apk, which is an application that has been signed.

Note that if our project is dependent on other projects, we also need to create those projects ant environment, such as android applications will generally rely on android-support-v7-appcompat, at this time, we need to run the second step of the command on cd to this project, and we can see that there is a build. xml. Otherwise you may see the following error: build failed f: \ android \ adt-bundle-windows-x86-20140321 \ sdk \ tools \ ant \ build. xml: 471: Invalid

File: F: \ android \ adt-bundle-windows-x86-20140321 \ sdk \ extras \ android \ support \ v7 \ appcompat \ build. xml and other errors, This is intended in the appcompat Project No ant Environment


If it is reprinted, enter the original address. Thank you.


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.