博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android: How To Decode ProGuard’s Obfuscated Code
阅读量:6415 次
发布时间:2019-06-23

本文共 3235 字,大约阅读时间需要 10 分钟。

hot3.png

(This post is for Android developers who use  in their app and need to do some debugging with the encrypted stack trace. It’s really simple to return the file to a human-readable condition.)

BEFORE

Here’s the stack trace as obfuscated by ProGuard:

Caused by: java.lang.NullPointerExceptionat net.simplyadvanced.ltediscovery.be.u(Unknown Source)at net.simplyadvanced.ltediscovery.at.v(Unknown Source)at net.simplyadvanced.ltediscovery.at.d(Unknown Source)at net.simplyadvanced.ltediscovery.av.onReceive(Unknown Source)

AFTER

All you need to do is write one line in the command prompt, and the obfuscation will be removed, as you can see here:

Caused by: java.lang.NullPointerExceptionat net.simplyadvanced.ltediscovery.UtilTelephony.boolean is800MhzNetwork()(Unknown Source)at net.simplyadvanced.ltediscovery.ServiceDetectLte.void checkAndAlertUserIf800MhzConnected()(Unknown Source)at net.simplyadvanced.ltediscovery.ServiceDetectLte.void startLocalBroadcastReceiver()(Unknown Source)at net.simplyadvanced.ltediscovery.ServiceDetectLte$2.void onReceive(android.content.Context,android.content.Intent)(Unknown Source)

HOW TO DECODE STACK TRACE

You can choose either the command line method or GUI (Graphical User Interface) method.

HOW TO DECODE STACK TRACE VIA GUI

1) Open /tools/proguard/bin/proguardgui.bat 2) Select the “ReTrace” option on the left column. 3) Add your mapping file and obfuscated stack trace. 4) Click “ReTrace!”

Thanks to David Bilik for mentioning this GUI method.

HOW TO DECODE STACK TRACE VIA COMMAND LINE

1) You will need your ProGuard’s mapping.txt file and the stack trace (Ex: stacktrace.txt) that you want to de-obfuscate.
2) The easiest way to do the next step is copy both these files into your/tools/proguard/bin</span>. 3) If you are on Windows, **run the following command** in the same directory as the files (make sure you change to your own file names):

retrace.bat -verbose mapping.txt stacktrace.txt > out.txt

4) out.txt will have the stack trace de-obfuscated. Now you can debug much easier and faster than before.

ADVANCED INFO

Technically, you don’t need the -verbose command or  > out.txt. But, I choose to add them in order to make debugging even easier. I give an example with and without the -verbose command above. If you don’t include  > out.txt in the command line, then the results will just appear in the command prompt. This command basically says to “send all output to out.txt”. “out.txt” is just an arbitrary name that I made up.

NOTE

Make sure your ProGuard’s mapping.txt is from the same version of your compiled version. Mapping.txt gets replaced and changes every time you export your APK from Eclipse. A good idea is to copy and store all of your mapping.txt files in a safe location that won’t get rewritten. Also, adding your app’s version number at the end will make your process a lot simpler also, i.e., “mapping_v3p0p8.txt”.

For Linux/Mac users, replace retrace.bat with retrace.sh.

Here’s some more information about .

I hope this was direct enough for those Android developers that use ProGuard.

 -  -

Co-Founder and Lead Developer of Simply Advanced, LLC

ps – Check out my Simply Advanced Android apps on Google Play:  and .

转载于:https://my.oschina.net/u/255456/blog/541553

你可能感兴趣的文章
JAVA中的TreeSet
查看>>
关于checked="checked"却不显示选中的“对勾”
查看>>
三、MySQL PHP 语法
查看>>
实现文件与目录快速遍历
查看>>
【洛谷 p3386】模板-二分图匹配(图论)
查看>>
Deferred Shading 延迟着色(翻译)
查看>>
zabbix ZBX_NOTSUPPORTED: Timeout while executing a shell script.
查看>>
炒鸡好用的头文件
查看>>
动画!
查看>>
【爬虫综合作业】猫眼电影TOP100分析
查看>>
写一个方法,求两个数的最大公约数和最小公倍数。
查看>>
MyEclipse2014中SVN的使用方法
查看>>
java09 面向对象,封装,继承,多态
查看>>
IoC模式(依赖、依赖倒置、依赖注入、控制反转)
查看>>
Struts 基础开发---day01
查看>>
webpack之跨域
查看>>
网站优化之分辨率
查看>>
20140711 eat 并查集
查看>>
Ruby on Rails入门篇
查看>>
MVC_HtmlHelper用法大全
查看>>