使用AndResGuard混淆资源文件

来源:互联网 发布:java中的除法运算 编辑:程序博客网 时间:2024/06/07 10:24

github地址 : https://github.com/shwenzhang/AndResGuard

里边说可以直接配置build.gradle ,不过弄了半天各种错误.



需要准备如下几样东西 : 




1 arg.jar : 就是github中的tool_output里边的jar包改个名字



2 build.bat : 新建txt ,修改后缀名称 然后加入下边的命令

java -jar arg.jar ip.apk -config config.xml -out release -zipalign E:\AndroidStudio\SDK\build-tools\23.0.2\zipalign -7zip "C:/Program Files (x86)/7-Zip/7z.exe" -signature C:/Users/Administrator/Desktop/cc.jks 123456798 123456798 ccc

其中,里边的zipalign路径,7zip路径,签名文件路径和密码需要自己修改

最后的三个参数 "123456798 123456798 ccc" 对应的是 "密码 align的密码 align名称"



3 config.xml , 里边的一些路径修改成自己的

<?xml version="1.0" encoding="UTF-8"?><resproguard>    <!--defaut property to set  -->    <issue id="property">        <!--whether use 7zip to repackage the signed apk, you must install the 7z command line version in window -->        <!--sudo apt-get install p7zip-full in linux -->        <!--and you must write the sign data fist, and i found that if we use linux, we can get a better result -->        <seventzip value="false"/>         <!--the sign data file name in your apk, default must be META-INF-->        <!--generally, you do not need to change it if you dont change the meta file name in your apk-->        <metaname value="META-INF"/>        <!--if keep root, res/drawable will be kept, it won't be changed to such as r/s-->        <keeproot value="false"/>    </issue>    <!--whitelist, some resource id you can not proguard, such as getIdentifier-->    <!--isactive, whether to use whitelist, you can set false to close it simply-->    <issue id="whitelist" isactive="true">        <!--you must write the full package name, such as com.tencent.mm.R -->        <!--for some reason, we should keep our icon better-->        <!--and it support *, ?, such as com.tencent.mm.R.drawable.emoji_*, com.tencent.mm.R.drawable.emoji_?--><path value="yzx.ppw.R.drawable.ic_launcher"/><path value="yzx.ppw.R.mipmap.ic_launcher"/><path value="yzx.ppw.R.string.app_name"/>        <path value="com.xmonster.letsgo.R.drawable.icon"/>        <path value="com.xmonster.letsgo.R.string.umeng*"/>        <path value="com.xmonster.letsgo.R.layout.umeng*"/>        <path value="com.xmonster.letsgo.R.drawable.umeng*"/>        <path value="com.xmonster.letsgo.R.anim.umeng*"/>        <path value="com.xmonster.letsgo.R.color.umeng*"/>        <path value="com.xmonster.letsgo.R.style.*UM*"/>        <path value="com.xmonster.letsgo.R.style.umeng*"/>        <path value="com.xmonster.letsgo.R.id.umeng*"/>    </issue>    <!--keepmapping, sometimes if we need to support incremental upgrade, we should keep the old mapping-->    <!--isactive, whether to use keepmapping, you can set false to close it simply-->    <!--if you use -mapping to set keepmapping property in cammand line, these setting will be overlayed-->    <!-- <issue id="keepmapping" isactive="false"> -->        <!--the old mapping path, in window use \, in linux use /, and the default path is the running location-->        <!--<path value="{your_mapping_path}"/> -->    <!--</issue> -->    <!--compress, if you want to compress the file, the name is relative path, such as resources.arsc, res/drawable-hdpi/welcome.png-->    <!--what can you compress? generally, if your resources.arsc less than 1m, you can compress it. and i think compress .png, .jpg is ok-->    <!--isactive, whether to use compress, you can set false to close it simply-->    <issue id="compress" isactive="false">        <!--you must use / separation, and it support *, ?, such as *.png, *.jpg, res/drawable-hdpi/welcome_?.png-->        <path value="*.png"/>        <path value="*.jpg"/>        <path value="*.jpeg"/>        <path value="*.gif"/>        <path value="resources.arsc"/>    </issue>    <!--sign, if you want to sign the apk, and if you want to use 7zip, you must fill in the following data-->    <!--isactive, whether to use sign, you can set false to close it simply-->    <!--if you use -signature to set sign property in cammand line, these setting will be overlayed-->    <issue id="sign" isactive="true">        <!--the signature file path, in window use \, in linux use /, and the default path is the running location-->        <path value="C:/Users/Administrator/Desktop/cc.jks"/>        <!--storepass-->        <storepass value="123456798"/>        <!--keypass-->        <keypass value="123456798"/>        <!--alias-->        <alias value="ccc"/>    </issue></resproguard>


4 ip.apk 就是自己的apk ,签没签名都行



双击build.bat运行 然后就会在同级目录中出现个release文件夹,里边内容 : 



用压缩格式打开ip_signed_aligned.apk,里边有个文件夹r,就是混淆后的资源文件 :


打开后 :


OK






2 0