Android Batch Build channel pack

Source: Internet
Author: User

1. Load ant on www.apache.org and configure Ant's running environment on your computer (my resources share the ant package downloaded from Apache, you can also download it by yourself)

2. Test whether the installation is successful

Start-and-run--cmd--enter ant carriage return, indicating that the ant environment settings are configured if the following prompt appears

3, in order to allow Ant to batch build Android APK file, you need to Ant-contrib-1.0b3.jar (my resources have this file can be downloaded) file into Ant's lib directory

4. Specify the ant directory in Eclipse (do not use Eclipse's own ant) Window-->prefercens

5. Create Android Test Batch package project

Create several files under Engineering: (That is, the project's root directory, with the SRC, Res is a peer relationship)

(1) Build.xml

(2) Local.properties

(3) Ant.properties

To illustrate, the relationship between the three files, the Build.xml file is the most important file, local.properties and ant.properties files are referenced in the Build.xml file, that is, the settings of some variables are mainly set in these two files.

The source code is as follows:

Build.xml

<?xml version= "1.0" encoding= "UTF-8"?><!--project name createapk, can be replaced globally with the current project name--><project name= "createapk" D         efault= "Deploy" > <!--the local.properties file is created and updated by the ' Android ' tool. It contains the path to the SDK.    It should *not* is checked into Version Control Systems. --<property file= "local.properties"/> <!--the ant.properties file can created by you.         It is only edited by the ' Android ' tool to add properties to it.         The "the" to "change some Ant specific build properties. Here is some properties want to change/update:source.dir the name of the source directory.         Default is ' src '. Out.dir the name of the output directory.          Default is ' bin '.          For other overridable properties, look at the beginning of the rules files in the SDK, at Tools/ant/build.xml Properties related to theThe SDK location or the project target should is updated using the ' Android ' tool with the ' Update ' action. This file is a integral part of the build system for your application and should are checked into Version Control    Systems.  --<property file= "ant.properties"/> <!--the project.properties file is created and updated          By the ' Android ' tool, as well as ADT. This contains project specific properties such as project target, and library dependencies.          Lower level build properties is stored in ant.properties (or in. classpath for Eclipse projects). This file is a integral part of the build system for your application and should are checked into Version Control    Systems.        --<loadproperties srcfile= "Project.Properties"/> <!--quick check on Sdk.dir-<fail Message= "Sdk.dir is missing. Make sure to generate Local.properties using ' Android update Project ' or to inject it through an env var "unless=" Sdk.dir "/> <!--extension targets. Uncomment the ones where you want to does custom work on between standard targets-<!--<target Nam E= "-pre-build" > </target> <target name= "-pre-compile" > </target> <target name= "-post-c         Ompile > </target> <!--Import the actual build file. To customize existing targets, there is, options:-Customize only one target:-Copy/paste the TA             Rget into this file, *before* the <import> task.         -Customize it to your needs.               -Customize the whole content of build.xml-copy/paste the content of the rules files (minus the top node)             Into this file, replacing the <import> task.         -Customize to your needs. IMPORTANT ****** **********In all cases-must update the value of Version-tag below to read ' custom ' instead of an integer, In order to avoid have your file is overridden by tools such as "Android Update Project"-<!--ve            Rsion-tag:1--<taskdef resource= "Net/sf/antcontrib/antcontrib.properties" > <classpath>     <pathelement location= "D:/ant/lib/ant-contrib-1.0b3.jar"/> </classpath> </taskdef> <import file= "${sdk.dir}/tools/ant/build.xml"/> <target name= "Deploy" > <foreach de        Limiter= "," list= "${market_channels}" param= "Channel" target= "Modify_manifest" > </foreach> </target> <target name= "Modify_manifest" > <!--<replaceregexp file= "A            Ndroidmanifest.xml "encoding=" Utf-8 "match=" android:value= "(. *)" "replace=" "/>--<replaceregexp      Byline= "false"      Flags= "G" > <regexp pattern= "android:name=" Umeng_channel "android:value=" (. *) ""/>                <substitution expression= "android:name=" Umeng_channel "android:value=" ${channel} "/> <fileset Dir= "" includes= "Androidmanifest.xml"/> </replaceregexp> <!--& Lt;property name= "Out.release.file" value= "${out.absolute.dir}/${channel}.apk"/>---<antcall target= "re Lease "/> <copy tofile=" ${gos.path}/${ant.project.name}_${publish.date}_${channel}.apk "> < Fileset dir= "${out.absolute.dir}/" includes= "${ant.project.name}-release.apk"/> & Lt;/copy> <delete includeemptydirs= "true" > <fileset dir= "${out.absolute.dir } "includes=" **/* "/> </delete> <echo message=" ============= generate a apk============ = = "/> </target> </project> 


Local.propertieslocal.properties

Sdk.dir=d:/android-sdk-windows


Ant.properties

application.package=com.test.createapkant.project.name=createapkjava.encoding=utf-8out.absolute.dir=e:/apk/ compilegos.path=e:/apk/createapkkey.store=d:/keystore/key.keystorekey.store.password=hy123456key.alias= Chinakey.alias.password=hy123456app_version=1.0.0market_channels=1001,1002publish.date=2015-1-7


The interpretation is as follows:

A, package name

B. Project name

C, Project code

d, temporary file storage location

E, apk file storage location

F, the secret key is located

g, secret key password

H, secret key aliases

I, alias password

J, Version

K, channel name, to be separated by commas, must be in a row

L, Release date

6. Operation and Generation

(1) Check if the directories you have configured have already created folders on your local disk

(2) Check that the files set and referenced in the Build.xml file (local.properties, ant.properties) are ready.

(3) Right-click Build.xml file-->run as--> ant Build

Android Batch Build channel pack

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.