转载自Android通过Mapping.txt还原混淆过后的代码
如何恢复混淆过后的代码文件,这个时候需要用到mapping.txt文件。
mapping文件:用来查看混淆前和混淆后的对比文件。一般用来查看线上的bug的log日志。
mapping文件目录: Android Studio中模块的build\outputs\mapping\release。
具体实现步骤:
1.打开Android SDK的proguardgui.bat工具(在SDK的tools\proguard\bin目录下)
2.在打开的ProGuard界面中,选择Retrace选项
3.在Mapping file选择app混淆对应的mapping.txt文件
4.在Obfuscated stack trace框里,输入异常信息
5.点击ReTrace!按钮,异常信息中混淆的类和方法就恢复了
注意:为了方便排查,混淆文件需要增加以下内容:
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable