How to deobfuscate an Android stacktrace using mapping file
Asked Answered
F

3

32

I got a stacktrace from the crashreporting system and it is obfuscated, like

... Failed resolution of: Lru/test/c/b/a; ...

I have a mapping file.

How to deobfuscate this stacktrace using mapping.txt?

Fastigium answered 6/5, 2019 at 14:11 Comment(0)
T
44

Get deobfuscated crash stacktrace from your app page

Upload your mapping.txt to your app PlayStore page with the following steps:

  1. Sign in to your Play Console.
  2. Select an app.
  3. On the left menu, click Android vitals > Deobfuscation files.
  4. Next to a version of your app, click Upload.
  5. Upload the ProGuard mapping file for the version of your app.

After doing so, to view your deobfuscated crash stack traces:

  1. Sign in to your Play Console.
  2. Select an app.
  3. On the left menu, click Android vitals > ANRs & Crashes.
  4. Select a crash.
  5. On the "Stack Traces" tab, you'll see your deobfuscated stack traces.

You can check this link for more details.

Deobfuscate a piece of stacktrace

To convert the code by yourself use the retrace script (retrace.bat on Windows; retrace.sh on Mac/Linux). It is located in the ~/Android/sdk/tools/proguard/bin/ directory. The script takes the mapping.txt file and your stack trace, producing a new, readable stack trace. The syntax for using the retrace tool is:

retrace.bat|retrace.sh [-verbose] mapping.txt [<stacktrace_file>]
Trounce answered 6/5, 2019 at 14:26 Comment(8)
The retrace script seems to be remove from the SDK or it is not in the path anymore. Your command is not working for me. It can be found in: ~/Library/Android/sdk/tools/proguard/bin/retrace.shSklar
I've updated my answer @Janusz. Actually the <sdk-root> was already there but since i did not annotate it with '`' it was not showing, I only noticed it now. A bit late from my side but thanks for the heads upTrounce
@Ricard how can I find my proguard file path in windowsPaniagua
Error running 'retrace.bat -verbose mapping.txt obfuscated_trace.txt': Cannot run program "retrace.bat" (in directory "C:\Users\Edgar\AndroidStudioProjects\Swapit_Android\app"): CreateProcess error=2, The system cannot find the file specifiedPaniagua
@Ricard I found where proguard installed I runned following command I am using windows and I am running following command retrace.bat [-verbose] mapping.txt but I am getting following error Error: [-verbose] (The system cannot find the file specified)Paniagua
you need to replace [<stacktrace_file>] with your obfuscated file, e.g: my_obfuscated_file.txt. The command should look like: retrace.bat -verbose mapping.txt obfuscated_stack_trace.txtTrounce
I used retrace.sh [-verbose] mapping.txt [<stacktrace_file>] worked and really helpful since app center doesn't retrace issues before uploaded mapping file. thanks mateWindowsill
Notice that the stack trace must start with "at": https://mcmap.net/q/454418/-proguard-retrace-not-working-with-stacktrace-runtime-info-like-e-androidruntime-10237Moreno
R
21

We can use pro-guard tool to retrace :

1st get the mapping file from the below location

<project-path>app/build/outputs/mapping/flavor/release/mapping.txt

Find the pro-guard tool i.e. "proguardgui" from the below location

<your-computer-name>/AppData/Local/Android/SDK/tools/proguard/lib

then you will get proguardgui.jar

On mac : /Users/<your computer name>/Library/Android/sdk/tools/proguard/lib

By using terminal

java -jar /Users/<your computer name>/Library/Android/sdk/tools/proguard/lib/proguardgui.jar

proguardgui tool

Now click on the retrace option on the left menu side to get the below window, browse your mapping.txt file from the above location and add your stack trace error logs in the obfuscated stack trace window and then click on the ReTrace button to get the deObfuscated error report.

There is one more way of doing automatically using Google play store console.

Check this website of Google Play Store Console for detailed steps.

Resonance answered 3/11, 2021 at 13:49 Comment(2)
Oh my, this is incredible. All this time I've been doing it by hand T.TWatery
Bro, I can't thank enough you.. You're a Life savior.. Was banging my head on wall till now because, Firebase is not showing deobfuscated stacktrace and in Android Studio, it is showing obfuscated trace. Now, I can simply copy the trace and paste in GUI.. Viola..Potomac
F
1

Another option (works for me).
Location: C:\Program Files\Android\Android Studio\jre\bin (java.exe is here)

  1. Add the files from Sdk\tools\proguard\lib:

    proguard.jar

    retrace.jar

  2. Add your mapping.txt and stacktrace file

  3. Create a bat file with the lines:

    java -jar retrace.jar -verbose mapping.txt stacktrace

    pause

  4. Run it.

Forfeit answered 16/2, 2022 at 18:42 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.