[android deverlop 学习笔记]ProGuard代码混淆
来源:互联网 发布:淘宝暗语大全 编辑:程序博客网 时间:2024/05/20 08:41
一、ProGuard代码混淆的意义:
proguard代码混淆就是用一些无意义的字母来替代类名和函数名。它可以帮助去掉一些无用的代码和类,减小apk文件。同时,用无意义的字母代替类和方法名,可以防止反编译。
二、ProGuard代码混淆的方法:
1、设置proguard文件
使用Eclipse生成工程的时候,会在根目录自动生成一个proguard.cfg的文件,只需要把“proguard.config=proguard.cfg”这一句添加到project.properties文件里面。
2、设置proguard属性
proguard有时候会误删一些类,一下几种情况会导致误删:
1)只在 AndroidManifest.xml 文件定义的类
2)jni调用的方法
3)动态引用的方法或字段
为了防止这些误删,可以在proguard.cfg里,设置“-keep”,表示不对某些方法混淆。例如,设置:
-keep public class <MyClass>
可以不对MyClass进行混淆。当然,keep还有 很多别的选项可以设置,据需参考keep的帮助文档。
三、发布apk
在Eclipse中,可以file--export菜单中,找到发布apk的向导。然后就可以发布apk了。这时候,就会在工程的根目录里生成一个文件夹proguard,里面包含四个文件:
dump.txt:
Describes the internal structure of all the class files in the .apk file
mapping.txt
Lists the mapping between the original and obfuscated class, method, and field names. This file is important when you receive a bug report from a release build, because it translates the obfuscated stack trace back to the original class, method, and member names. See Decoding Obfuscated Stack Traces for more information.
seeds.txt
Lists the classes and members that are not obfuscated
usage.txt
Lists the code that was stripped from the .apk
其中,mapping.txt描述混淆代码和原始代码之间的队员关系,在debug的时候,很有用。
有一点要注意,每次发布apk,都会把之前的文件都覆盖掉,所以,为了debug,需要向办法把progurad生成的文件保存起来。
四、从Stack Traces得出原始代码
当程序错误抛出异常生成Stack Traces之后,以下方法可以从混淆的代码中,得到原始的代码:
retrace.bat -verbose mapping.txt obfuscated_trace.txt
- [android deverlop 学习笔记]ProGuard代码混淆
- Android代码混淆工具Proguard学习
- Android代码混淆工具Proguard学习
- android 代码混淆proguard
- android 代码混淆proguard
- Android proguard代码混淆
- Android proguard 混淆代码
- android 代码混淆 proguard
- android混淆代码-proguard
- Android-Proguard代码混淆
- Android ProGuard代码混淆
- Android proguard 代码混淆
- Android ProGuard代码混淆
- Android proguard代码混淆
- Android proguard代码混淆
- 【Android】【代码混淆】ProGuard
- Android 4.0 ProGuard 代码混淆
- Android混淆代码工具ProGuard
- POJ3280--Cheapest Palindrome
- 使用openssl API编写client和server
- Java多线程之一
- Android消息处理机制——Looper,Handler,Message,MessageQueue,Thread
- mac shell 设置dns
- [android deverlop 学习笔记]ProGuard代码混淆
- 解决ubuntu启动器启动应用从新图标启动问题
- thinkphp中数据查询注意点
- 石子归并
- 黑马程序员 --- OC中@property和@synthesize的用法
- C语言实现字符串分割(类似vb中split函数)
- 解决 RHEL 7/ CentOS 7/Fedora 出现Unit iptables.service failed to load
- Android:利用Style和include标签来减少布局中的重复代码
- PHP的readfile函数和file_get_contents函数错误: Unable to find the wrapper "https"