(This post is for Android developers who use ProGuard 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.)html
BEFORE
Here’s the stack trace as obfuscated by ProGuard:java
Caused by: java.lang.NullPointerException at 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:android
Caused by: java.lang.NullPointerException at 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.app
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!」ide
Thanks to David Bilik for mentioning this GUI method.post
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):ui
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.this
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.idea
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」.spa
For Linux/Mac users, replace retrace.bat with retrace.sh.
Here’s some more information about ProGuard 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 Converter and LTE Discovery.