How Decode an obfuscated stack trace logs in Android

How Decode an obfuscated stack trace logs in Android

Obfuscated stack trace After ProGuard, reading a stack trace is difficult (if not impossible) because the method names are obfuscated. Fortunately, ProGuard creates a mapping.txt file each time it runs, which shows the original class, method, and field names mapped to the obfuscated names. ProGuard saves the file in the app <module-name>/build/outputs/mapping/release/  directory.

Be aware that the mapping.txt file is overwritten every time you create a release build with ProGuard, so you must carefully save a copy each time you publish a new release. By retaining a copy of the mapping.txt  file for each release build, you’ll be able to debug a problem if a user submits an obfuscated stack trace from an older version of your app.

When publishing your app on Google Play, you can upload the mapping.txt file for each version of your APK. Then Google Play will deobfuscate incoming stack traces from user-reported issues so you can review them in the Google Play Console. For more information, see the Help Center article about how to deobfuscate crash stack traces.

To convert an obfuscated stack trace to a readable one yourself, use the retrace script (retrace.bat on Windows;retrace.sh on Mac/Linux). It is located in the <sdk-root>/tools/proguard/ directory. The script takes themapping.txt file and your stack trace, producing a new, readable stack trace. The syntax for using the retrace tool is:

Steps for Decode an obfuscated stack trace

1. From Command line

For example:

You can do with UI as well

2. Using Progaurd GUI

run below command in terminal/cmd

windows will open like below image

obfuscated stack trace

Click on ReTrace button

Read Logs after progaurd in android

Browse mapping.txt file from your release foler relative path would be

you can load txt file using Load stack trace

hope this tutorial help you.

Top Kotlin blog

Leave a Comment