Release builds

Readable stack traces from a Flutter release build — R8 mapping files on Android, dSYMs on iOS, and what happens to Dart stack traces with --obfuscate and --split-debug-info.

A Flutter release build has two kinds of code, and their stack traces resolve differently. Java, Kotlin, Objective-C and Swift code is resolved by Sophonz from the files you upload: R8 mapping files on Android and dSYMs on iOS. Dart code reports its own stack trace as text, which Sophonz shows as sent. Whether that text is readable depends on the flags you build with.

What resolves where

Stack traceComes fromResolved by
Android JVM crash or exception (plugins, MainApplication, the Android SDK)the Android SDKSophonz, with the build's mapping.txt
iOS crash (Swift, Objective-C, plugins, the Flutter engine)the Apple SDKSophonz, with the build's dSYMs
Dart error (exception.stacktrace on an error log)the Dart runtimeNot resolved by Sophonz. Readable unless you build with --split-debug-info or --obfuscate

Sophonz does not process Dart symbol files or Android native .so symbols.

Dart stack traces

Default release build

flutter build apk, flutter build appbundle and flutter build ipa without extra flags keep Dart function names in the AOT snapshot. Dart errors arrive with readable frames such as #0 CheckoutRepository.submit (package:shop/checkout/repository.dart:42). Nothing needs uploading.

--split-debug-info

This flag moves Dart debug information out of the app into a directory on the build machine, which makes the app smaller. Stack traces from such a build carry addresses instead of names:

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 12345, tid: 12400, name 1.ui
os: android arch: arm64 comp: yes sim: no
build_id: '4f5a2...'
isolate_dso_base: 7a1c2e3000, vm_dso_base: 7a1c2e3000
#00 abs 0000007a1c4f21b3 virt 00000000002b31b3 _kDartIsolateSnapshotInstructions+0x1c21b3

Sophonz stores and shows this text as is. To read it, keep the symbols directory of every release you ship and resolve the trace locally with flutter symbolize:

flutter build appbundle --release --split-debug-info=build/symbols/1.4.0+12
 
# later, with the exception.stacktrace value saved to trace.txt, header lines included
flutter symbolize -i trace.txt -d build/symbols/1.4.0+12/app.android-arm64.symbols

Use the symbols file for the architecture in the trace (app.android-arm64.symbols, app.ios-arm64.symbols, …). The build_id line ties the trace to one build; symbols from another build give wrong results.

--obfuscate

--obfuscate renames Dart classes and functions and requires --split-debug-info. Resolve addresses with flutter symbolize as above. To translate obfuscated names that appear in messages, such as exception.type, save the obfuscation map at build time:

flutter build ipa --release \
  --obfuscate \
  --split-debug-info=build/symbols/1.4.0+12 \
  --extra-gen-snapshot-options=--save-obfuscation-map=build/symbols/1.4.0+12/obfuscation.json

The map is a flat JSON array that alternates original and obfuscated names.

CAUTION — Obfuscated type names reach your data

With --obfuscate, exception.type holds the obfuscated class name, so errors of the same type from two builds do not group together. If grouping by error type matters more than obfuscation, build without --obfuscate.

Store the symbols directory and map as build artifacts in CI, named by version and build number, because they cannot be regenerated for a build that already shipped.

Android: R8 mapping files

Flutter release builds run R8 on the Java and Kotlin code: your MainApplication, the plugins and the Sophonz Android SDK. The mapping for that code is written to:

build/app/outputs/mapping/release/mapping.txt

Flutter moves the Android build output to the project's top-level build/, so the path is not under android/app/build/.

Upload with the Gradle plugin

The Sophonz Gradle plugin applied during installation uploads the mapping when R8 finishes. Set the upload host:

android/gradle.properties
sophonz.baseUrl=https://app.sophonz.ai

and the credentials in the same sophonz-config.json that holds the service key:

android/app/src/main/sophonz-config.json
{
  "app_id": "sophz",
  "api_token": "sophonz_pat_...",
  "sdk_config": {
    "app_framework": "flutter",
    "ingest": { "service_key": "sk_replace_me", "service_namespace": "my-project" }
  }
}

In CI, leave api_token out of the file and pass SOPHONZ_API_TOKEN (and SOPHONZ_APP_ID) as environment variables to flutter build:

- name: Build Android release
  env:
    SOPHONZ_API_TOKEN: ${{ secrets.SOPHONZ_TOKEN }}
    SOPHONZ_APP_ID: sophz
  run: flutter build appbundle --release

The plugin generates a build ID, embeds it in the app and uploads the mapping under it, so traces and mappings are matched per build. Token, app_id and plugin properties are described in Android mapping file upload.

Upload with the CLI

Without the plugin upload, send the file after the build. The Android app version is the versionName, which Flutter takes from the part of pubspec.yaml's version before +.

npx @sophonz/cli upload-mapping \
  --file build/app/outputs/mapping/release/mapping.txt \
  --version 1.4.0

iOS: dSYMs

flutter build ipa archives the app to build/ios/archive/Runner.xcarchive. Its dSYMs folder holds the dSYMs for the app and its embedded frameworks. Upload the whole folder:

flutter build ipa --release
 
PLIST=build/ios/archive/Runner.xcarchive/Products/Applications/Runner.app/Info.plist
npx @sophonz/cli upload-dsym \
  --file build/ios/archive/Runner.xcarchive/dSYMs \
  --version "$(/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' "$PLIST")" \
  --build-id "$(/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' "$PLIST")"

CFBundleShortVersionString and CFBundleVersion are the two parts of pubspec.yaml's version (1.4.0+12). dSYMs match by image UUID, so the version only organizes the list. The token, Build Phase upload and API are in iOS dSYM upload.

Checklist for a release

  1. Decide on --split-debug-info and --obfuscate. If you use them, archive the symbols directory and obfuscation map per build.
  2. Android: build with the Gradle plugin upload configured, or run upload-mapping after the build.
  3. iOS: run upload-dsym on the archive's dSYMs folder.
  4. Check Settings > project > app > Mapping files for the new version once the build sends telemetry.

Next