现在的位置: 首页 > 综合 > 正文

利用ant在Mac 下自动化打包签名Android程序

2012年12月11日 ⁄ 综合 ⁄ 共 1457字 ⁄ 字号 评论关闭

1.创建一个android项目

参数说明:-k /--package 为命名空间(包名)-a /--name 工程名-p /--path 项目 -t 为目标平台的版本编号

命令:./android create project -k com.android.yunju -a yunju -t 5 -p ~/Download/yunju 

列出不同平台的版本编号命令:android list targets

 2、已有项目更新

以创建的项目更新ant对已经存在的android工程,可以update下(修改平台的版本),这样会自动添加build.xml 等ant 的配置文件

命令:./android update project --name yunju -t 5 -p ~/Documents/YunJU/

当然,你要在android sdk tools的目录下。

3、命令行编译打包

参考:http://developer.android.com/tools/building/building-cmdline.html

ant 参数如下:

debug:带调试用签名的构建 release:构建应用程序,生成的apk必须签名才可以发布

install:安装调试构建的包到运行着的模拟器或者设备;

reinstall

uninstall

在Android项目文件下:ant debug ,会打包出来调试签名的apk。

4、release打包方式

在ant.properties 文件中添加

key.store=path/to/my.keystore
key.alias=mykeystore
key.store.password=wodemima
key.alias.password=wodemima

再运行:ant release

-release-sign:
     [echo] Signing final apk...
  [signapk] Run cancelled: no changes to input file /Users/rongfzh/Documents/YunJU/bin/yunju-release-unsigned.apk
 [zipalign] Run cancelled: no changes to input file /Users/rongfzh/Documents/YunJU/bin/yunju-release-unaligned.apk
     [echo] Release Package: /Users/rongfzh/Documents/YunJU/bin/yunju-release.apk
[propertyfile] Updating property file: /Users/rongfzh/Documents/YunJU/bin/build.prop
[propertyfile] Updating property file: /Users/rongfzh/Documents/YunJU/bin/build.prop
[propertyfile] Updating property file: /Users/rongfzh/Documents/YunJU/bin/build.prop
[propertyfile] Updating property file: /Users/rongfzh/Documents/YunJU/bin/build.prop

-post-build:

release:

BUILD SUCCESSFUL
Total time: 2 seconds

生成三个apk,其中一个就是签名好的发布的apk了。

也可以打包完成立即安装:ant release install

抱歉!评论已关闭.