android 友盟多渠道打包工具,使用ANT+Umeng工具实现多渠道打包编译APK

Android app开发完成以后第一项工作就是推广,因为国内的应用市场太多,APK会发布到各个应用商店,所以对每个渠道的推广效果进行监控就变的很有必要。

我个人采用了ANT+Umeng多渠道打包工具解决了上面这个问题。很多大牛一个ANT就搞定所有事了。之前在网上研究了很多关于ANT多渠道自动打包的文章,看的很累。如果不追求极致的话,采用我目前的方法效果也是一样的。好了,马上进入正题。

我使用的ADT版本是22.62,关于ANT的编译会用到3个文件:

build.xml

local.properties

ant.properties

平时我们调试的时候Eclipse会结合ANT自动帮我们生成Debug签名版的APK,所以我想到系统应该在某个地方已经配置好相关的build.xml文件了。果不其然在ANDROID_SDK目录下发现了一个Build文件(sdk/tools/ant/build.xml),这应该就是Debug的时候ANT所使用的build文件了。所以在我自己写的build文件中就引用到了它,同时也引用到local.properties和ant.properties这两个文件。

build.xml具体内容如下:

message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."

unless="sdk.dir"

/>

local.properties在这里的作用就是指定ANDROID_SDK的路径

local.properties详细内容如下:

# This file is automatically generated by Android Tools.

# Do not modify this file -- YOUR CHANGES WILL BE ERASED!

#

# This file must *NOT* be checked into Version Control Systems,

# as it contains information specific to your local configuration.

# location of the SDK. This is only used by Ant

# For customization when using a Version Control System, please read the

# header note.

sdk.dir=D:\\adt-bundle-windows-x86-20140321-20140805\\adt-bundle-windows-x86-20140321\\sdk

ant.properties 文件中需要指定签名证书,别名,签名密码等。

ant.properties 详细内容如下:

# This file is used to override default values used by the Ant build system.

#

# This file must be checked into Version Control Systems, as it is

# integral to the build system of your project.

# This file is only used by the Ant script.

# You can use this to override default values such as

# 'source.dir' for the location of your java source folder and

# 'out.dir' for the location of your output folder.

# You can also use it define how the release builds are signed by declaring

# the following properties:

# 'key.store' for the location of your keystore and

# 'key.alias' for the name of the key to use.

# The password will be asked during the build when you use the 'release' target.

key.store=E:\\***\\***

key.alias=*****

key.store.password=****

key.alias.password=****

把这3个文件放到Eclipse项目的根目录:

bVcRL9

最后运行build文件就可以编译打包了。

如果你在项目中用到了其他的第三方项目工程,那么依样画葫芦即可(复制这3份文件到你所引用的工程文件根目录即可)

如果有初学者不明白的可以邮件给我:wuyiqi2003@gmail.com

友盟渠道打包工具主要是提供基本的通过工程源码打包的功能。 常见错误见这里目前不支持的Apk特性见这里(可能会导致发布的SDK产生严重bug)。 Google 现在已经发布了最新的构建系统(New Building System) , 在 Android Studio 中已经支持了最新的 构建系统,如果开发者已经迁移,可以使用新的系统方面的生成渠道包,这是取代渠道打包工具的最佳方式。 1. 工程结构 工程结构图 : - CommonTools 共用的工具类,包括对 `Apktool` , `Jarsigner` , `zipalign` 的封装 - UIControls_35   共用的UI类,对大部分控件的样式都是在这里设置的 - UmengMarket  Marekt 组件,现在还没有实现UmengPackage 打包组件 - UmengTools 工程主要UI,管理 UmengMarket, UmengPackage, UmengTools 三个组件 - UmengWidget 小工具组件,目前仅有解包分析的功能 打包工具组件: - Source - Builder - ApkBuilder.cs     通过 APK 打包的 Builder 实现                    - Builder.cs            抽象 Builder 类,提供打包的主要逻辑                    - SourceBuilder.cs通过源码打包的 Builder 实现 (目前代码还没有实现)          - Worker.cs 打包过程对外接口 3. 打包流程 V2.0 版本仅实现了通过 .apk 打包的方式,本质上对  apk 文件进行反编译,修改 AndroidManifest.xml 文件后,再重新打包,我们使用工具是开源的拆包工具 Apktool 将  apktool  添加到当前 process 的环境变量 执行 apktool d --no-src -f xxxx.apk temp 拆解apk 替换或者添加 AndroidManifest.xml 中的 友盟channel 执行apktool b temp  unsigned.apk 重新打包apk 执行 SignApk.jar 生成签名后的 apk 文件 执行 zipAlign 生成对齐优化后的 apk 文件 回到 3 替换新的渠道 完成打包 使用  JarSigner.jar 给 Apk 签名, SignApk.jar  文件是我们修改过的 apk 签名工具实现了和 ADT 中一样的签名方式,使用如下: Usage: signapk file.{keystore} keystore_password key_entry key_password input.apk output.apk
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值