(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.)
Here’s the stack trace as obfuscated by ProGuard:
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)
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.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.
HOW TO DECODE STACK TRACE VIA GUI
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
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.
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.
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 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