如果你没有看过上篇 基于AndroidSDK的Ant环境配置 (一) ,那就先去看吧.
配置
查看 project.properties
1 | # This file is automatically generated by Android Tools. |
从文件中可以看到, project.properties
是告诉 Ant
需要编译的目标API版本,你可以手动修改版本号或是在 android update project
命令时添加 -t API版本号
参数.
注意看这两行:
1 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): |
第二行是决定 Ant
编译时是否启用 Proguard
来对程序进行代码混淆和优化的选项,把注释符去掉即可启用.
当 Proguard
启用时, Ant
会先到 AndroidSDK
的对应目录下加载默认的混淆参数,然后再加载项目目录下的 proguard-project.txt
,我们可以在这文件中添加自定义的参数.
为了方便浏览,我们不在这里启用 Proguard
,而是在 local.properties
中配置.
配置 local.properties
1 | # This file is automatically generated by Android Tools. |
可以看到在文件中已经帮我们配置好 AndroidSDK
的位置了,接下来我们要在这里添加自己的配置.
1 | # This file is automatically generated by Android Tools. |
在这里我为 Ant
启用了 Proguard
.
有关
Proguard
的配置,请点击 这里 来查看详细的用法.
配置 ant.properties
可选项,如果不需要
1 | # 签名 |
在这里我为 Ant
指定了编译时使用的签名和密码.
现在我们就可以编译出带签名的程序了.