Android Ant批量打包

來源:互聯網
上載者:User

標籤:

一、配置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
View Code

二、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=應用版本
View Code
檔案二: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="(.*)"" />            <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 tofile="${gos.path}/應用程式名稱_${channel}.apk" >            <fileset                dir="${out.absolute.dir}/"                includes="應用程式名稱-release.apk" />        </copy>        <echo message="-------------------------------------------------------" />    </target></project>
View Code
檔案三:local.properties#sdk根目錄sdk.dir=/software/android-sdk-linux
View Code

三、在終端中切換到工程根目錄下執行命令:ant deploy  

打包成功後會顯示以下提示

BUILD SUCCESSFUL
Total time: 1 minute 58 seconds

  

 

Android Ant批量打包

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.