AndResGuard的使用

AndResGuard介绍:

微信资源压缩打包,主要为了混淆资源ID长度(例如将res/drawable/welcome.png混淆为r/s/a.png),同时利用7z深度压缩,大大减少了安装包体积,同时也增加了逼格,提升了反破解难度。

详情参考:https://github.com/shwenzhang/AndResGuard
原理介绍:
http://mp.weixin.qq.com/s?__biz=MzAwNDY1ODY2OQ==&mid=208135658&idx=1&sn=ac9bd6b4927e9e82f9fa14e396183a8f#rd

使用说明:

方法一:

使用命令行,在github上有详细介绍使用
eg:

java -jar AndResGuard-cli-1.1.0.jar input.apk -config config.xml -out outapk -zipalign  D:/android/android-sdks/build-tools/23.0.2/zipalign

可参考:github的例子,其中.bat为win下批处理命令,双击运行。

.sh为linux或mac下执行的脚本,通过

./buildApk.sh
方法二:

使用插件,同样的在github上也有说明,配置好之后在project目录下使用

>gradlew generate
方法三:

配置task任务
在project下目录的build.gradle中

/**
 *gradlew  compressReleaseApp
 * 对包进行微信资源压缩
 */
task compressReleaseApp {
    // 在现有release的版本上生成到compressed目录下
    def guardJarFile = file('/AndResGuard/AndResGuard-cli-1.1.0.jar') //AndResGuard jar包
    def guardConfigFile = file('config.xml') //config.xml配置文件
    def originApkFile = file("xxx.apk") //需要压缩的apk
    def outputDir = file("/build/AndResGuard/") //输出的位置
    // 开始执行压缩命令
    def proc = "java -jar ${guardJarFile} ${originApkFile} -config ${guardConfigFile} -out ${outputDir} -zipalign  D:/android/android-sdks/build-tools/23.0.2/zipalign".execute();
    proc.waitFor();
    println "return code: ${ proc.exitValue()}" + ", stderr: ${proc.err.text}" + " stdout: ${proc.in.text}"
}

在cmd中执行:gradlew compressReleaseApp

Demo地址,采用的是方法三的改进版,https://github.com/zouyuanfeng/AndResGuardDemo

结果

压缩后图片

注:在win下7Z的安装后如果没有7za.exe的话,可以把7z.exe复制一份改成7za.exe,并配置环境变量
描述

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值