APP混淆已经是APP发布时的标配技术了,但是我们经常需要去看用户使用APP时的崩溃日志,这个时候,看到的日志确是被混淆了,比如a.b.c.c()!就要狂了。所以,Google当然会为我们考虑到这种情况。下面对具体的使用进行说明。
代码混淆生成apk之后,项目下面会多出来一个build\outputs\mapping\release文件夹,下面分别解释release文件夹中四个文件的作用。
dump.txt : 描述了apk中所有类 文件中内部的结构体。( 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. )
seeds.txt : 列出了没有混淆的类和方法。( Lists the classes and members that are not obfuscated )
usage.txt : 列出congapk中删除的代码。( Lists the code that was stripped from the .apk )
1.cmd进入sdk/tools/proguard/bin目录。
2.将混淆后的日志cache_file_name.txt和上文提到的mapping文件放入此目录中。
3.执行命令:retrace.bat mapping.txt cache_file_name.txt
执行命令前:
Casused by: Java.lang.NullPointerException
at com.example.test d.a.c(SourceFile:110)
at com.example.test d.a.c(SourceFile:88)
at com.example.test .activity.CommitFragmentBase.init(SourceFile:1330)
执行命令后:
Casused
by: java.lang.NullPointerException
at com.example.test loginActivity.login.setView(SourceFile:110)
at com.example.test dloginActivity.login.setView(SourceFile:88)
at com.example.test .activity.CommitFragmentBase.init(SourceFile:1330)