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
- Add the packages:
firebase_coreandfirebase_crashlytics(Flutter). - 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;
};
- Android: apply the Crashlytics Gradle plugin; release builds upload mapping files automatically.
- 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.
- Set the user id to our opaque user id only, never an email or phone number.
- 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 see | It means |
|---|---|
| Crashes show addresses, not code | Symbols were not uploaded for that build |
| Nothing arrives | Collection is off in that build type, or the app was not reopened after the crash |
| Offline errors listed as crashes | Network 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.