Skip to main content

Crashlytics

What does it do?#

Crashlytics helps you to collect analytics and details about crashes and errors that occur in your app. It does this through three aspects:

  • Logs: Log events in your app to be sent with the crash report for context if your app crashes.
  • Crash reports: Every crash is automatically turned into a crash report and sent when the application next opens.
  • Stack traces: Even when an error is caught and your app recovers, the Dart stack trace can still be sent.

Installation#

1. Add dependency#

On the root of your Flutter project, run the following command to install the plugin:

flutter pub add firebase_crashlytics

2. (optional) Platform integration#

Dart-only Firebase initialization currently only supports reporting Dart exceptions. To report native Android & iOS exception please follow the Android platform Setup section from the manual installation guide and the steps below.

a. Android#

  1. Add the following classpaths to your android/build.gradle file.
android/build.gradle
dependencies {
// ... other dependencies
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
}
  1. Apply the following to your android/app/build.gradle file.
android/app/build.gradle
// ... other imports
android {
// ... your android config
}
dependencies {
// ... your dependencies
}
// This must appear at the bottom of the file
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

b. iOS#

  1. From Xcode, select Runner from the project navigation.
  2. Select the Build Phases tab, then click + > New Run Script Phase.
  3. Add the following to the Type a script... text box underneath the Shell property:
$PODS_ROOT/FirebaseCrashlytics/upload-symbols --build-phase --validate -ai <googleAppId>
$PODS_ROOT/FirebaseCrashlytics/upload-symbols --build-phase -ai <googleAppId>

Retrieve your <googleAppId> from your generated DefaultFirebaseOptions file (appId) or from the Firebase Console -> Project Settings -> Your apps.

3. Rebuild your app#

Once complete, rebuild your Flutter application:

flutter run

Next steps#

Once installed, you're ready to start using Firebase Crashlytics in your Flutter Project. View the Usage documentation to get started.