Skip to main content

Crashlytics

What it is​

Firebase Crashlytics records app crashes on users' phones and groups them by cause. It uses the same Firebase projects as push notifications. To turn a crash into readable file names and line numbers, each release build uploads its symbols (dSYM files on iOS, mapping and symbol files on Android).

How to read Crashlytics and set version numbers is in Firebase Crashlytics (DevOps). This page is the setup.

Why we do it​

Sentry catches errors the app reports. Crashlytics catches the app dying, including native crashes Sentry can miss. The crash-free users rate is the number we watch after every release.

Before you start​

  • Firebase projects per environment from Push notifications.
  • A release build pipeline for each platform.

Steps​

  1. Add the packages: firebase_core and firebase_crashlytics (Flutter).
  2. Send uncaught errors to Crashlytics, and turn collection off in debug builds:
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(!kDebugMode);
FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterFatalError;
PlatformDispatcher.instance.onError = (e, s) {
FirebaseCrashlytics.instance.recordError(e, s, fatal: true);
return true;
};
  1. Android: apply the Crashlytics Gradle plugin; release builds upload mapping files automatically.
  2. iOS: add the Crashlytics run script build phase that uploads dSYMs, and check it still exists after any change from CocoaPods to Swift Package Manager.
  3. Set the user id to our opaque user id only, never an email or phone number.
  4. Turn on velocity alerts and new issue emails in the Crashlytics console, to the team mailbox.

Check it worked​

Add a hidden "test crash" button in the dev build that calls FirebaseCrashlytics.instance.crash(). Run a release build, tap it, reopen the app, and the crash appears in the console within a few minutes with readable frames.

If it goes wrong​

You seeIt means
Crashes show addresses, not codeSymbols were not uploaded for that build
Nothing arrivesCollection is off in that build type, or the app was not reopened after the crash
Offline errors listed as crashesNetwork errors are sent as fatal. Record them as non-fatal

Done when​

  • Crashlytics in every flavor, off in debug.
  • Symbols uploaded by the release build on both platforms.
  • Alerts go to the team mailbox.
  • A test crash from a release build arrived with readable frames.