firebase_crashlytics 0.1.2+4

  • Readme
  • Changelog
  • Example
  • Installing
  • 100

firebase_crashlytics plugin #

A Flutter plugin to use the Firebase Crashlytics Service.

pub package

For Flutter plugins for other Firebase products, see

Usage #

Import the firebase_crashlytics plugin #

To use the firebase_crashlytics plugin, follow the plugin installation instructions.

Android integration #

Enable the Google services by configuring the Gradle scripts as such:

  1. Add the Fabric repository to the [project]/android/build.gradle file.
repositories {
  // Additional repository for fabric resources
  maven {
    url ''
  1. Add the following classpaths to the [project]/android/build.gradle file.
dependencies {
  // Example existing classpath
  classpath ''
  // Add the google services classpath
  classpath ''
  // Add fabric classpath
  classpath ''
  1. Apply the following plugins in the [project]/android/app/build.gradle file.
apply plugin: 'io.fabric'
apply plugin: ''

Note: If this section is not completed, you will get an error like this:

Default FirebaseApp is not initialized in this process [package name].
Make sure to call FirebaseApp.initializeApp(Context) first.

Note: When you are debugging on Android, use a device or AVD with Google Play services. Otherwise, you will not be able to use Firebase Crashlytics.

iOS Integration #

Add the Crashlytics run scripts:

  1. From Xcode select Runner from the project navigation.
  2. Select the Build Phases tab.
  3. Click + Add a new build phase, and select New Run Script Phase.
  4. Add ${PODS_ROOT}/Fabric/run to the Type a script... text box.
  5. If you are using Xcode 10, add the location of Info.plist, built by your app, to the Build Phase's Input Files field.

Use the plugin #

Add the following imports to your Dart code:

import 'package:firebase_crashlytics/firebase_crashlytics.dart';

Setup Crashlytics:

void main() {
  // Set `enableInDevMode` to true to see reports while in debug mode
  // This is only to be used for confirming that reports are being
  // submitted as expected. It is not intended to be used for everyday
  // development.
  Crashlytics.instance.enableInDevMode = true;

  // Pass all uncaught errors from the framework to Crashlytics.
  FlutterError.onError = Crashlytics.instance.recordFlutterError;

Overriding FlutterError.onError with Crashlytics.instance.recordFlutterError will automatically catch all errors that are thrown from within the Flutter framework.
If you want to catch errors that occur in runZoned, you can supply Crashlytics.instance.recordError to the onError parameter:

runZoned<Future<void>>(() async {
    // ...
  }, onError: Crashlytics.instance.recordError);

Result #

If an error is caught, you should see the following messages in your logs:

flutter: Flutter error caught by Crashlytics plugin:
// OR if you use recordError for runZoned:
flutter: Error caught by Crashlytics plugin <recordError>:
// Exception, context, information, and stack trace in debug mode
// OR if not in debug mode:
flutter: Error reported to Crashlytics.

Note: It may take awhile (up to 24 hours) before you will be able to see the logs appear in your Firebase console.

Example #

See the example application source for a complete sample app using firebase_crashlytics.

Issues and feedback #

Please file Flutterfire specific issues, bugs, or feature requests in our issue tracker.

Plugin issues that are not specific to Flutterfire can be filed in the Flutter issue tracker.

To contribute a change to this plugin, please review our contribution guide, and send a pull request.

0.1.2+4 #

  • Updated the example with the missing recordError() method.
  • Added a recordError() integration test.

0.1.2+3 #

  • Remove the deprecated author: field from pubspec.yaml
  • Migrate the plugin to the pubspec platforms manifest.
  • Bump the minimum Flutter version to 1.10.0.

0.1.2+2 #

  • Removed the async from the runZoned() in the example, as there's no await to be executed.

0.1.2+1 #

  • Updated a confusing comment.

0.1.2 #

  • Updated to use the v2 plugin API.

0.1.1+2 #

  • When reporting to Crashlytics on iOS, and printing supplied logs, do not prepend each line with "FirebaseCrashlyticsPlugin.m line 44".
  • Prepend firebase_crashlytics: to the final answer from Crashlytics plugin in the log to realize where it's coming from.

0.1.1+1 #

  • Updated README instructions for contributing for consistency with other Flutterfire plugins.

0.1.1 #

  • Log FlutterErrorDetails using Flutter's standard FlutterError.dumpErrorToConsole.
  • In debug mode, always log errors.

0.1.0+5 #

  • Fix example app support-compat crash by setting compileSdkVersion to 28.

0.1.0+4 #

  • Fix linter finding in examples.

0.1.0+3 #

  • Update documentation to reflect new repository location.
  • Update unit tests to call TestWidgetsFlutterBinding.ensureInitialized.

0.1.0+2 #

  • [iOS] Fixes crash when trying to report a crash without any context

0.1.0+1 #

  • Added additional exception information from the Flutter framework to the reports.
  • Refactored debug printing of exceptions to be human-readable.
  • Passing null stack traces is now supported.
  • Added the "Error reported to Crashlytics." print statement that was previously missing.
  • Updated to include both the breaking change from 0.1.0 and the newly added recordError function in the setup section.
  • Adjusted formatting.
  • Fixed recordFlutterError method name in the 0.1.0 changelog entry.

0.1.0 #

  • Breaking Change Renamed onError to recordFlutterError.
  • Added recordError method for errors caught using runZoned's onError.

0.0.4+12 #

  • Update google-services Android gradle plugin to 4.3.0 in documentation and examples.

0.0.4+11 #

  • Fixed an issue where Crashlytics#getStackTraceElements didn't handle functions without classes.

0.0.4+10 #

  • Update README.

0.0.4+9 #

  • Fixed custom keys implementation.
  • Added tests for custom keys implementation.
  • Removed a print statement.

0.0.4+8 #

  • Automatically use version from pubspec.yaml when reporting usage to Firebase.

0.0.4+7 #

  • Fixed an issue where Crashlytics#setUserIdentifier incorrectly called setUserEmail on iOS.

0.0.4+6 #

  • On Android, use actual the Dart exception name instead of "Dart error."

0.0.4+5 #

  • Fix parsing stacktrace.

0.0.4+4 #

  • Add missing template type parameter to invokeMethod calls.
  • Bump minimum Flutter version to 1.5.0.

0.0.4+3 #

  • Migrate our handling of FlutterErrorDetails to work on both Flutter stable and master.

0.0.4+2 #

  • Keep debug log formatting.

0.0.4+1 #

  • Added an integration test.

0.0.4 #

  • Initialize Fabric automatically, preventing crashes that could occur when setting user data.

0.0.3 #

  • Rely on firebase_core to add the Android dependency on Firebase instead of hardcoding the version ourselves.

0.0.2+1 #

  • Update variable name enableInDevMode in README.

0.0.2 #

  • Updated the iOS podspec to a static framework to support compatibility with Swift plugins.
  • Updated the Android gradle dependencies to prevent build errors.

0.0.1 #

  • Initial release of Firebase Crashlytics plugin. This version reports uncaught errors as non-fatal exceptions in the Firebase console.


firebase_crashlytics_example #

Demonstrates how to use the firebase_crashlytics plugin.

Getting Started #

Add your own Firebase project #

This example initially uses a default project for CI purposes. You must replace the default project with your own so that you can review the error reports submitted to the Firebase console.

See docs for how to add Firebase to a Flutter project.

For further help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  firebase_crashlytics: ^0.1.2+4

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:firebase_crashlytics/firebase_crashlytics.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
stack_trace ^1.9.3 1.9.3
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
path 1.6.4
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
e2e ^0.2.1
test ^1.5.1