firebase_crashlytics 0.1.1+2

  • Readme
  • Changelog
  • Example
  • Installing
  • 99

firebase_crashlytics plugin #

A Flutter plugin to use the Firebase Crashlytics Service.

pub package

For Flutter plugins for other Firebase products, see README.md.

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 {
  google()
  jcenter()
  // Additional repository for fabric resources
  maven {
    url 'https://maven.fabric.io/public'
  }
}
  1. Add the following classpaths to the [project]/android/build.gradle file.
dependencies {
  // Example existing classpath
  classpath 'com.android.tools.build:gradle:3.2.1'
  // Add the google services classpath
  classpath 'com.google.gms:google-services:4.3.0'
  // Add fabric classpath
  classpath 'io.fabric.tools:gradle:1.26.1'
}
  1. Apply the following plugins in the [project]/android/app/build.gradle file.
// ADD THIS AT THE BOTTOM
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

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

java.lang.IllegalStateException:
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.
    E.g.: $(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)

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;
  
  runApp(MyApp());
}

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.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 README.md to include both the breaking change from 0.1.0 and the newly added recordError function in the setup section.
  • Adjusted README.md 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.

example/README.md

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:


dependencies:
  firebase_crashlytics: ^0.1.1+2

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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
99
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
99
Learn more about scoring.

We analyzed this package on Nov 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.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.7 1.1.8
path 1.6.4
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_driver
flutter_test
test ^1.5.1