First, configure the ant environment variable
java_home=/software/jdk1.6. 0_24ant_home=/software/apache-ant-1.9.2android_home=/software/ android-sdk-linuxexport java_home ant_home android_homepath= $JAVA _home/bin: $ANT _home/bin: $ANDROID _home/ tools$android_home/tools/proguard/bin:$/software/decompile/dex2jar-0.0.9.13: $PATHexport PATHCLASSPATH= /SOFTWARE/APACHE-ANT-1.9.2/libexport CLASSPATH
View Code
Second, copy the following three files to the project root directory
file One: ant.propertiesout.absolute.dir= output apk directory ant.project.name= project name Gos.path= Compile-related directories such as output mapping files Key.alias=alias name java.encoding=utf-8key.store.password= Password application. package =Cn.ibm.moa.android.cfkey.store=KeyStore directory Key.alias.password= Alias password market_channels=a01,a02,a03 (channel name, multi-channel separated by commas) app_version= App version
View Code
file Two: build.xml (red ones need to be modified according to their own circumstances)<?xml version= "1.0" encoding= "UTF-8"?><Project Name= "Project Name"default= "Help" > <property file= "local.properties"/> <property file= "ant.properties"/> <loadproperti Es 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"/> <taskdef resource= "net/sf/antcontrib/antcontrib.properties" > <classpath> &L t;! ---<pathelement location= "/software/apache-ant-1.9.2/lib/ant-contrib-1.0b3.jar"/> in ant directory </classpath> </taskdef> <Importfile= "${sdk.dir}/tools/ant/build.xml"/> <Importfile= "Custom_rules.xml"Optional= "true"/> <target name= "Clean_bin_gen" > <echo>cleaning the project ...</echo> <delete dir= "${report.dir}"/> <delete dir= "${build.dir}"/> <Delete Includeemptydirs= "true"verbose= "true" > <Fileset dir= "Bin"includes= "**/*" > </fileset> </delete> <Delete Includeemptydirs= "true"verbose= "true" > <Fileset dir= "Gen"includes= "**/*" > </fileset> </delete> </target> <Target Name= "Deploy"depends= "Clean" > <foreach delimiter=","List= "${market_channels}"param= "Channel"Target= "Modify_manifest" > </foreach> </target> <target name= "Modify_manifest" > <re Placeregexp byline= "false" > <regexp pattern= "android:debuggable=" (. *) ""/> <substitutio n expression= ""/> <Fileset dir=""includes= "Androidmanifest.xml"/> </replaceregexp> <replaceregexp byline= "false"Flags= "G" > <regexp pattern= "android:name=" app_channel "* (\ r \ n)? *android:value= "(. *)" "/> <substitution expression=" android:name= "App_channel" android:value= "${channel}" "/> <Fileset dir=""includes= "Androidmanifest.xml"/> </replaceregexp> <replaceregexp byline= "false"Flags= "G" > <regexp pattern= "android:name=" app_channel01 "* (\ r \ n)? *android:value= "(. *)" "/> <substitution expression=" android:name= "app_channel01" android:value= "${channel } ""/> <Fileset dir=""includes= "Androidmanifest.xml"/> </replaceregexp> <antcall target= "release"/> <copy tofil E= "${gos.path}/app name _${channel}.apk" > <Fileset dir= "${out.absolute.dir}/"includes= "app name-release.apk"/> </copy> <echo message= "-------------------------------------------------- -----"/> </target></project>View Code
file three: local.properties#sdk root directory Sdk.dir=/software/android-sdk-linux
View Code
Iii. switch to the project root in the terminal Execute command: Ant deploy
The following prompt is displayed when packaging is successful
BUILD Successful
Total time:1 minute seconds
Android Ant Bulk Pack