android ant 打包须知

来源:互联网 发布:dw cs6连接数据库 编辑:程序博客网 时间:2024/05/29 04:56

1.最近项目上线需要用到ant,有些问题。

2.

首先去下载一个ant ,然后在环境变量里配置 ant_home类似java_home,然后在cmd下输入ant ,如果提示 build.xml not exist 说明安装成功了

然后cd到项目目录下,然后ant deploy 命令


custom_rules.xml里的内容

3.

<?xml version="1.0" encoding="UTF-8"?><project name="custom_rules"><taskdef resource="net/sf/antcontrib/antcontrib.properties"><classpath><pathelement location="ant-libs/ant-contrib-1.0b3.jar" /></classpath></taskdef><target name="deploy"><foreach delimiter="," list="${market_channels}" param="channel"target="modify_manifest"></foreach></target><target name="modify_manifest"><replaceregexp byline="false" encoding="UTF-8" flags="g"><regexppattern="android:name="UMENG_CHANNEL"([\w\W]*)android:value="(.*)"" /><substitutionexpression="android:name="UMENG_CHANNEL" android:value="${channel}"" /><fileset dir="" includes="AndroidManifest.xml" /></replaceregexp><property name="out.final.file"location="${apk.dir}/${app_name}${app_version}@${channel}.apk" /><antcall target="clean" /><antcall target="release" /><antcall target="clean" /></target></project>


该xml是在build.xml中被import进去的。

代码如下:

    <import
        file="custom_rules.xml"
        optional="true" />


里面

ant-contrib-1.0b3.jar
需要是第三方的,如果没有的话,可能会导致ant deploy会错,jar包是负责循环打包的


还有一个 local_properties里定义了一些如下属性,这些地址分别在custom_rules.xml和jar包里被用到,包括找到安卓反编译等需要用到的tool,都在一下地址中

sdk.dir=F:\\andorid_home\\adt-bundle-windows-x86_64-20140702\\sdk
sdk.platformtools=F:\andorid_home\adt-bundle-windows-x86_64-20140702\sdk\\platform-tools
sdk.tools=F:\andorid_home\adt-bundle-windows-x86_64-20140702\sdk\\tools
apk.dir="最后输出包的路径,必须先建好,不然会报zipalign无法打开某压缩包,这个蛋疼"
app_version=1.0
app_name="项目名字,这个和buind里的project节点的name应该一致"
market_channels=official,baidu,tencent,qihoo,wandoujia,google,anzhi,xiaomi,huawei,appchina,sougou,pp,oppo,youyi,woshop,meizu,leshop,yidong,vivo,nduo,9200,gfan,xxzx
key.store="keystore的路径"
key.store.password=123456
key.alias=xxx
key.alias.password=123456 


market_channels为渠道号

0 0
原创粉丝点击