Sub topic 7
Obfuscation and Split Debug Info
This chapter assumes you can build a Flutter app from the command line and understand Dart release builds. You should also know how to read a stack trace and keep build artifacts in version control or a build archive.
A release build contains information that helps tools describe Dart code. That information makes crash reports easier to read, but it also adds bytes and exposes useful names. Flutter provides two related options:
- Obfuscation renames many Dart symbols, such as class and method names.
- Split debug info removes symbol information from the shipped app and writes it to a separate directory.
These options reduce the information included in the app. They do not encrypt the app or make reverse engineering impossible.
Build with both options
Use the options when creating a release artifact, such as an Android App Bundle:
flutter build appbundle \
--release \
--obfuscate \
--split-debug-info=build/symbolsThe --split-debug-info value is a directory. Flutter writes symbol files there while building the app. Keep this directory private and archive it with the exact version of the app that you ship.
You can also use the options for an APK:
flutter build apk \
--release \
--obfuscate \
--split-debug-info=build/symbolsThe result is a smaller and less descriptive binary. The exact size reduction depends on the amount of symbol information in the application.
How crash decoding works
After obfuscation, a Dart stack trace can contain short names that do not match your source code. The symbol files provide the mapping from those names back to the original names and locations.
Save a crash report as a text file, then decode it with the matching symbol directory:
flutter symbolize \
-i crash.txt \
-d build/symbolsThe input must be a Dart stack trace that belongs to the same build that produced the symbol files. A symbol directory from another commit, platform, or build cannot reliably decode the trace.
What the options do and do not protect
| Technique | Main effect | Important limitation |
|---|---|---|
| `--obfuscate` | Renames many Dart symbols | Does not hide strings, assets, or all native code |
| `--split-debug-info` | Stores Dart symbol mappings outside the app | You must retain the matching files |
| Both together | Smaller, less descriptive release artifacts | Decoding fails or loses detail without correct symbols |
Obfuscation can make debugging harder during development. Use it for release artifacts, and test the release build before publishing. Confirm that your crash-reporting process can upload or access the matching symbols.
Obfuscation is a size and information-reduction technique, not a security boundary. Never place passwords, API keys, or other secrets in Dart code, assets, or strings because obfuscation does not reliably remove their meaning.
A repeatable release check
For each release, record:
- The commit and Flutter version.
- The target platform and architecture.
- The app size before and after the options.
- The location of the archived symbol files.
- A test crash decoded with the release's symbols.
This process lets you measure the benefit while preserving useful diagnostics.
Exercise
Why must the symbol files be archived separately for every release?
Show answer
Obfuscation creates build-specific name mappings. A crash report can be decoded only with the symbols generated for the exact app build that produced it.