成功:Android批量打包教程
(2013-02-19 13:36:53)
1.配置JAVA的环境变量
2.
下载Ant(这里的Ant不是eclipse和android SDk里面自带的ant)
3. 解压Ant并配置环境变量
路径均用反斜杠)
4. 验证ant配置是否正确
但是Ant不支持循环,怎样循环打包? 扩展包Ant-contrib能轻松解决这个问题.可以翻墙的同学可以到http://ant-contrib.sourceforge.net/自行下载,下载后直接把ant-contrib-1.0b3.jar放到Ant的lib文件夹即可.
5. 编写build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="ThumbPlay" default="help">
<!-- extension targets. Uncomment the ones where you want to do custom work
<!--
-->
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
</taskdef>
<import file="${sdk.dir}/tools/ant/build.xml" />
<target name="deploy">
</target>
<target name="modify_manifest">
<!--<replaceregexp file="AndroidManifest.xml" encoding="utf-8" match="android:value="(.*)"" replace=""/>-->
<!--<property name="out.release.file" value="${out.absolute.dir}/${channel}.apk"/>-->
<copy tofile="${gos.path}/ThumbPlay_${channel}.apk">
</copy>
<delete includeEmptyDirs="true">
</delete>
<echo message="==========================="/>
</target>
</project>
6. 配置local.properties
7. 配置ant.properties
# the config file for batch package.
application.package=com.leyou.thumb
(你的
apk
文件的包名)
ant.project.name=ThumbPlay
(你的
apk
文件的工程名)
java.encoding=utf-8
out.absolute.dir=C:/compile
gos.path=Z:/app-version/test
(打好的渠道包要放到的目的位置)
key.store=D:/androidApk/thumbplay/thumbplay.keystore
(keystore
文件路径
)
key.store.password=wushenshiji999
(keystore
文件路径
)
key.alias=muzhigame
(
keystore
文件别名)
key.alias.password=wushenshiji999
(
keystore
文件别名密码)
app_version=1.0.4
(要打的渠道包的版本名称)
market_channels=guanwang,shuihu,wushen,shenhua,huawei
(渠道名称,要以逗号分隔,必须在一行内)
8. 最后一步,修改AndroidManifest.xml文件:
9.生成渠道包
备注:
再增加一些看到的优秀博文:
ANT英文官方教程
:
http://ant.apache.org/manual/index.html
有些同志还将 jenkins + ant(jenkins就是一个计划任务)联合起来使用。