How to read an obfuscated stack trace in Firebase Crashlytics in Flutter

Mohit Gupta
3 min readJan 21, 2024

--

At Wheelseye Technology, we leverage a combination of the Native and Flutter development ecosystems to enhance productivity and optimize development time. On the native side, we have obfuscated all Dart code using the following snippet

extra-gen-snapshot-options=--obfuscate

So when Firebase reports a Flutter crash, the stack trace is often obfuscated and challenging to interpret. However, there is a workaround to make the stack trace readable by following a few steps. Here’s a guide on how to achieve this:

Step 1: Navigate to the root level of your project, which contains the pubspec.yaml file:

cd apps/flutter_project

Step 2: Confirm your location by checking the directory contents:

ls

The output on the terminal should be as follows.

README.md                               lib
analysis_options.yaml
assets pubspec.lock
build pubspec.yaml
flutter_01.log pubspec_overrides.yaml
flutter_02.log test

Ensure that the output includes the pubspec.yaml file.

Step 3: Now, execute the following command in the terminal:

flutter build apk --obfuscate --split-debug-info=<path of folder where files will be generated> --extra-gen-snapshot-options=--save-obfuscation-map=<name of the file>

For example, I used the following command to generate the mapping file.

flutter build apk --obfuscate --split-debug-info=/Users/rishyash/Desktop/code_mapping
--extra-gen-snapshot-options=--save-obfuscation-map=/Users/rishyash/Desktop/code_mapping/mappingFile

After executing the command, Flutter generates the mapping file in the directory we specified. The results can be found as follows.

Step 4: Now, open this file, and you can view the mapping content. Copy the content and paste it on the provided website. Then, click on “Format code” for better readability.

Step 5: Once the code is formatted we will find data in key value pair. For example, ["MaterialApp", "ex", "Scaffold", "ey"], where ex is the obfuscated name of MaterialApp.

Firebase crash stack trace

Step 6: Now we can find the values of obfuscated values.
For Example VF.Tqb is converted to AnimationController.stop
so AnimationController is the class name, and stop is its method of that class.

We can search for it in the entire project and address the root cause.

Output

VF.Tqb (pNh:778) what we get from firebase and here is what we have decoded. Also we can see that it is pointing to same line number 778 of the code.

For more reference you can visit Obfuscate Dart code.

Happy coding!
Mohit Gupta
Flutter Developer
GitHub Profile

--

--