首页 > 代码库 > Android Ant批量打包
Android Ant批量打包
一、配置Ant环境变量
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
二、copy以下三个文件到工程根目录
文件一:ant.propertiesout.absolute.dir=输出apk目录ant.project.name=工程名字gos.path=输出mapping文件等编译相关目录key.alias=alias名称java.encoding=utf-8key.store.password=密码application.package=cn.ibm.moa.android.cfkey.store=keystore目录key.alias.password=alias密码market_channels=a01,a02,a03(渠道名,多渠道以逗号隔开)app_version=应用版本
文件二:build.xml(红色部分需要根据自己的情况修改)<?xml version="1.0" encoding="UTF-8"?><project name="工程名" default="help" > <property file="local.properties" /> <property file="ant.properties" /> <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" /> <taskdef resource="net/sf/antcontrib/antcontrib.properties" > <classpath> <!-- ant目录下的lib --> <pathelement location="/software/apache-ant-1.9.2/lib/ant-contrib-1.0b3.jar" /> </classpath> </taskdef> <import file="${sdk.dir}/tools/ant/build.xml" /> <import file="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" > <replaceregexp byline="false" > <regexp pattern="android:debuggable="(.*)"" /> <substitution expression="" /> <fileset dir="" includes="AndroidManifest.xml" /> </replaceregexp> <replaceregexp byline="false" flags="g" > <regexp pattern="android:name="APP_CHANNEL" *(\r\n)? *android:value="http://www.mamicode.com/(.*)"" /> <substitution expression="android:name="APP_CHANNEL" android:value="http://www.mamicode.com/${channel}"" /> <fileset dir="" includes="AndroidManifest.xml" /> </replaceregexp> <replaceregexp byline="false" flags="g" > <regexp pattern="android:name="APP_CHANNEL01" *(\r\n)? *android:value="http://www.mamicode.com/(.*)"" /> <substitution expression="android:name="APP_CHANNEL01" android:value="http://www.mamicode.com/${channel}"" /> <fileset dir="" includes="AndroidManifest.xml" /> </replaceregexp> <antcall target="release" /> <copy tofile="${gos.path}/应用名称_${channel}.apk" > <fileset dir="${out.absolute.dir}/" includes="应用名称-release.apk" /> </copy> <echo message="-------------------------------------------------------" /> </target></project>
文件三:local.properties#sdk根目录sdk.dir=/software/android-sdk-linux
三、在终端中切换到工程根目录下执行命令:ant deploy
打包成功后会显示以下提示
BUILD SUCCESSFUL
Total time: 1 minute 58 seconds
Android Ant批量打包
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。