(This post is for Android developers who useProGuardin 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:

Causedby:java.lang.NullPointerExceptionatnet.simplyadvanced.ltediscovery.be.u(UnknownSource)atnet.simplyadvanced.ltediscovery.at.v(UnknownSource)atnet.simplyadvanced.ltediscovery.at.d(UnknownSource)atnet.simplyadvanced.ltediscovery.av.onReceive(UnknownSource)

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:

Causedby:java.lang.NullPointerExceptionatnet.simplyadvanced.ltediscovery.UtilTelephony.booleanis800MhzNetwork()(UnknownSource)atnet.simplyadvanced.ltediscovery.ServiceDetectLte.voidcheckAndAlertUserIf800MhzConnected()(UnknownSource)atnet.simplyadvanced.ltediscovery.ServiceDetectLte.voidstartLocalBroadcastReceiver()(UnknownSource)atnet.simplyadvanced.ltediscovery.ServiceDetectLte$2.voidonReceive(android.content.Context,android.content.Intent)(UnknownSource)

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-verbosemapping.txtstacktrace.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-verbosecommand or> out.txt. But, I choose to add them in order to make debugging even easier. I give an example with and without the-verbosecommand above. If you don’t include> out.txtin 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 aboutProGuard Decoding.

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

-Danial Goodwin-
Co-Founder and Lead Developer of Simply Advanced, LLC

ps – Check out my Simply Advanced Android apps on Google Play:SA Unit ConverterandLTE Discovery.


更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. android:tint
  2. android:定制checkbox 图片
  3. android 停止Handler
  4. 【Android Http Post】android post 请求
  5. Android 数据存储
  6. android开发指南中文版
  7. 阅读《Android(安卓)从入门到精通》(5)——
  8. android 动画模块分析
  9. Android TabHost Tutorial
  10. android API level