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
  • 1

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

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

./buildApk.sh
  • 1

方法二:

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

>gradlew generate
  • 1

方法三:

配置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

尊重作者劳动成果:https://blog.csdn.net/u014300915/article/details/50601940

发布了54 篇原创文章 · 获赞 20 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/csdn15002274757/article/details/103104427