Package selection guidance compiled from public package information, community data, and project usage.
Flutter Crashlytics is a plugin that integrates Firebase Crashlytics into Flutter apps for both Android and iOS, enabling automatic crash reporting. It allows developers to capture and send detailed crash logs, including custom messages and metadata, to help diagnose issues. The plugin enhances app stability by providing real-time insights into crashes and errors, supporting debugging and performance optimization. It seamlessly works with Firebase's backend services and offers tools for monitoring app health across platforms.
Use cases
Monitoring app crashes in production
Debugging runtime errors with detailed stack traces
Adding custom logs to crash reports
Tracking app stability over time
Integrating with Firebase analytics dashboards
Key features
Automatic crash detection
Custom log and metadata support
Cross-platform Android and iOS compatibility
Real-time crash reporting
Integration with Firebase Crashlytics dashboard
Suitable for
Mobile app developers using Firebase
Teams focused on app reliability
Projects requiring crash analytics
Developers building production-grade Flutter apps
Apps needing error tracking and diagnostics
Considerations
Requires Firebase project setup
Limited to Android and iOS platforms
Needs proper initialization in app startup
May require additional permissions on some devices
Custom logs should be used judiciously to avoid data overload
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
flutter_crashlytics
Flutter plugin to enable Crashlytics reporting.
Setup
Firebase Crashlytics
If you're using Firebase instead of Fabric, you must first setup your app to use Firebase as per this tutorial.
https://codelabs.developers.google.com/codelabs/flutter-firebase/#4
The instructions are the same for Fabric and Firebase, except that for Firebase, you don't get an API key so you don't have to add it anywhere.
Android
To setup Crashlytics on Android side, you need to set the Fabric ID in your manifest like this:
(Only do this if using Fabric, not Firebase as you will not have an API Key)
And apply the fabric plugin apply plugin: 'io.fabric'
Nothing more.
Symbolicating Native Android Crashes
Unfortunately, even pure Dart projects can't always protect you from native
crashes. Without the following setup, a native crash like SIGSEGV will
appear as a blank stacktrace in Crashlytics. Here's how to get some symbols:
Add the following to build.gradle, after apply plugin: 'io.fabric':
Ensure that the NDK bundle is installed or the stripDebugSymbol directory won't
get created.
Now setup a release script to populate the debugSymbols directory, guided by
the instructions from https://github.com/flutter/flutter/wiki/Crashes
# Build our app like usual
flutter -v build apk --release
### BEGIN MODIFICATIONS# Copy mergeJniLibs to debugSymbolscp -R ./build/app/intermediates/transforms/mergeJniLibs/release/0/lib debugSymbols
# The libflutter.so here is the same as in the artifacts.zip found with symbols.zipcd debugSymbols/armeabi-v7a
# Download the corresponding libflutter.so with debug symbols
ENGINE_VERSION=`cat$HOME/flutter/bin/internal/engine.version`
gsutil cp gs://flutter_infra/flutter/${ENGINE_VERSION}/android-arm-release/symbols.zip .
# Replace libflutter.so
unzip -o symbols.zip
rm -rf symbols.zip
# Upload symbols to Crashlyticscd ../../android
./gradlew crashlyticsUploadSymbolsRelease
### END MODIFICATIONS# Release your app like usualcd ../..
fastlane submit_playalpha
iOS
On iOS side you need to set your Fabric ID under your Info.plist like:
(Only do this if using Fabric, not Firebase as you will not have an API Key)
Turn off automatic collection with a new key to your Info.plist file (GDPR compliency if you want it):
Key: firebase_crashlytics_collection_enabled
Value: false
Don't forget to add your Run Script step (with any version of Xcode) on the build phases tab.
If using Xcode 10, you also must add your app's built Info.plist location to the Build Phase's Input Files field:
$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)
That's it :)
Flutter
All you need to do under your code is to let the plugin handle the Flutter crashes.
Your main method should look like:
voidmain() async {
bool isInDebugMode = false;
FlutterError.onError = (FlutterErrorDetails details) {
if (isInDebugMode) {
// In development mode simply print to console.FlutterError.dumpErrorToConsole(details);
} else {
// In production mode report to the application zone to report to// Crashlytics.Zone.current.handleUncaughtError(details.exception, details.stack);
}
};
awaitFlutterCrashlytics().initialize();
runZoned<Future<Null>>(() async {
runApp(MyApp());
}, onError: (error, stackTrace) async {
// Whenever an error occurs, call the `reportCrash` function. This will send// Dart errors to our dev console or Crashlytics depending on the environment.awaitFlutterCrashlytics().reportCrash(error, stackTrace, forceCrash: false);
});
}
forceCrash allows you to have a real crash instead of the red screen, in that case the exception will be tagged as fatal.
API available
Add log to crash reporting with log(String msg, {int priority, String tag})
Add manual log to crash reporting with logException(Error/Exception exception, Stacktrace stack)
Add user info to crash reporting with setUserInfo(String identifier, String email, String name)
Add general info to crash reporting with setInfo(String key, dyncamic value)
Limitation
This plugin uses Crashlytics SDK to log manual dart crashes, all manually logged crashes are tagged as non fatal under Crashlytics, that's a limitation of the SDK.
You can bypass that limitation with the forceCrash parameter, instead of the red screen an actual crash will be appended, the crash will be tagged as fatal.
On iOS fatal crash has their dart stacktrace under the Logs tab of Crashlytics, that's a limitation of iOS that prevents developers to set a custom stacktrace to an exception.
Contribution
We love contributions! Don't hesitate to open issues and make pull request to help improve this plugin.