Flutter Firebase Crashlytics Setup and What to Watch

· 5 min read

A crash you never hear about is a one-star review you will hear about. Firebase Crashlytics is the usual way to collect crash reports from a Flutter app on iOS and Android, and the setup takes about fifteen minutes. The parts people get wrong are the error handlers (so Dart errors actually reach Crashlytics) and symbols (so stack traces are readable after you obfuscate).

This post walks through setup, a test crash, symbols, and what to look at once reports start coming in. It is one step in building a Flutter app with Claude Code.

Before you start

You need Firebase already configured in the Flutter project, which means you have run flutterfire configure and call Firebase.initializeApp. If not, start with Firebase for Flutter with Claude Code.

Firebase also recommends enabling Google Analytics, because Crashlytics then collects breadcrumb logs: the screens and events leading up to a crash. Breadcrumbs are available on Android and Apple platforms except watchOS.

Step 1: add the plugins

From the project root:

flutter pub add firebase_crashlytics && flutter pub add firebase_analytics
flutterfire configure
flutter run

Re-running flutterfire configure matters: it keeps your config current and, on Android, adds the Crashlytics Gradle plugin for you. Skipping it is the most common reason Android reports never arrive.

Step 2: catch every kind of error

Flutter has two error paths, and Crashlytics needs a hook on both.

import 'dart:ui';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/material.dart';
import 'firebase_options.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );

  // Errors thrown inside the Flutter framework (build, layout, paint).
  FlutterError.onError =
      FirebaseCrashlytics.instance.recordFlutterFatalError;

  // Uncaught async errors that the framework does not see.
  PlatformDispatcher.instance.onError = (error, stack) {
    FirebaseCrashlytics.instance.recordError(error, stack, fatal: true);
    return true;
  };

  runApp(const MyApp());
}

FlutterError.onError covers framework errors. PlatformDispatcher.instance.onError covers uncaught asynchronous errors, for example a failed Future nobody awaited. Firebase’s customization guide also shows an Isolate.current.addErrorListener hook for errors outside the Flutter context; add it if you run work in your own isolates.

A note on fatal: true: marking every uncaught Dart error as fatal makes your crash-free numbers honest, but it also means a handled-looking error counts as a crash. That is usually what you want for uncaught errors.

Step 3: force a test crash

Add a temporary button:

TextButton(
  onPressed: () => throw Exception('Crashlytics test'),
  child: const Text('Throw test exception'),
)

Build, run, press it, then open Crashlytics in the Firebase console. Firebase’s guidance: if the crash “doesn’t appear after five minutes of refreshing the console,” turn on debug logging to see whether reports are being sent. Remove the button before release, or hide it behind a debug flag.

Test both platforms. A working iOS setup says nothing about Android, and the Gradle plugin issue above only shows up there.

Step 4: symbols for obfuscated builds

If you build release apps with --obfuscate and --split-debug-info (which also shrinks your app, see reducing Flutter app size), Crashlytics needs symbol files to turn stack traces back into readable function names.

Apple: use Flutter 3.12.0+ and Crashlytics Flutter plugin 3.3.4+ so dSYM files upload automatically.

Android: use Firebase CLI v11.9.0+ and upload after each build:

flutter build appbundle --obfuscate --split-debug-info=build/symbols
firebase crashlytics:symbols:upload --app=FIREBASE_APP_ID build/symbols

Two traps from the Firebase docs. FIREBASE_APP_ID is your Android Firebase App ID, “not your package name.” And upload the symbols before reporting crashes from that build. Put this command in your release script or Flutter CI/CD pipeline so it never gets skipped.

Step 5: make reports useful

A raw stack trace tells you where. Keys, logs and non-fatal errors tell you why.

final crashlytics = FirebaseCrashlytics.instance;

// State at the time of a crash.
crashlytics.setCustomKey('plan', 'pro');
crashlytics.setCustomKey('screen', 'checkout');

// Breadcrumbs you write yourself.
crashlytics.log('Started restore purchases');

// An anonymous ID, never an email.
crashlytics.setUserIdentifier(user.uid);

// A caught error you still want to see.
try {
  await syncNow();
} catch (e, s) {
  crashlytics.recordError(e, s, reason: 'sync failed');
}

Know the limits Firebase lists:

  • “Crashlytics supports a maximum of 64 key-value pairs.”
  • “Each key-value pair can be up to 1 kB in size.”
  • “Crashlytics limits logs to 64kB and deletes older log entries when logs for a session go over that limit.”
  • “Crashlytics only stores the most recent eight recorded non-fatal exceptions.”

Also, non-fatal events on mobile “are logged on-device and then sent along with the next fatal event report,” so they can appear later than you expect.

Opt-in reporting and privacy

Collection is automatic by default. If you want consent first, turn it off in native config:

  • iOS: add FirebaseCrashlyticsCollectionEnabled to Info.plist with the value false.
  • Android: add a meta-data tag named firebase_crashlytics_collection_enabled with the value false inside <application> in AndroidManifest.xml.

Then call FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true) once the user agrees.

Either way, crash data is data collection. Declare it in Apple’s privacy details and Google’s Data safety form. See the app privacy labels guide and the Google Play Data safety form guide. Keep user identifiers anonymous; do not put emails or names in keys or logs.

What to watch after launch

Once real users arrive, a short routine beats staring at the dashboard:

  1. New issues after each release. Filter by the latest version the day after rollout. A new top issue usually means a regression.
  2. Affected users by version. If the new version crashes for more people than the last one did, stop widening the rollout until you know why.
  3. The top three issues by users affected, not by event count. One user crashing in a loop can inflate counts.
  4. Keys on the top issue. If every crash has screen=checkout, you know where to look.
  5. Non-fatals for silent failures, like sync or purchase restore errors that never crash but still break the app.

Put this in your weekly app monitoring routine, and add “force a test crash on both platforms” to your mobile app QA checklist before each major release.

Quick checklist

  • firebase_crashlytics and firebase_analytics added, flutterfire configure re-run.
  • FlutterError.onError and PlatformDispatcher.instance.onError both set.
  • Test crash seen in the console from iOS and Android.
  • Android symbol upload in the release script; Flutter and plugin versions high enough for automatic dSYMs.
  • Custom keys for plan, screen and app state; anonymous user ID only.
  • Privacy labels and Data safety updated.

MobileKit’s build and QA skills set up these handlers and run the test-crash check as part of a release.

Sources read on the day this post was written: Firebase: Get started with Crashlytics for Flutter, Firebase: Customize Crashlytics reports for Flutter and Firebase: Customize crash reports overview.

Questions

Do I need to do anything extra for obfuscated Flutter builds?

Yes. On Android, Firebase says to upload symbols with firebase crashlytics:symbols:upload before reporting crashes from obfuscated builds. On Apple platforms, Flutter 3.12.0+ with Crashlytics Flutter plugin 3.3.4+ uploads dSYM files automatically.

How long until a test crash shows in the Firebase console?

Firebase says that if the test crash does not appear after five minutes of refreshing the console, you should enable debug logging to check whether reports are being sent.

How many custom keys can Crashlytics store?

Crashlytics supports a maximum of 64 key-value pairs, each up to 1 kB. Logs are limited to 64kB per session and only the most recent eight non-fatal exceptions are stored.

Try it on your next idea

One payment, every update to this major version, and a refund window if it is not for you. Refund policy.