Flutter-Plugin zur Aktivierung von Crashlytics-Meldungen für Android und iOS sowie zur Möglichkeit, benutzerdefinierte Protokolle und Informationen zu den Berichten hinzuzufügen.
Aus öffentlichen Paketdaten erstellte Orientierung.
Flutter Crashlytics ist ein Plugin, das Firebase Crashlytics in Flutter-Anwendungen für Android und iOS integriert und automatische Absturzberichterstattung ermöglicht. Es ermöglicht Entwicklern, detaillierte Absturzprotokolle einschließlich benutzerdefinierter Nachrichten und Metadaten zu erfassen und zu senden, um Probleme zu diagnostizieren. Das Plugin verbessert die Stabilität der Anwendung durch Echtzeit-Einblicke in Abstürze und Fehler und unterstützt Debugging sowie Leistungsoptimierung. Es arbeitet nahtlos mit den Backend-Diensten von Firebase zusammen und bietet Tools zur Überwachung der App-Gesundheit über Plattformen hinweg.
Anwendungsfälle
Anwendungsrunterschläge in der Produktion überwachen
Debuggen von Laufzeitfehlern mit detaillierten Stacktraces
Benutzerdefinierte Protokolle zu Absturzberichten hinzufügen
Stabilität der App im Laufe der Zeit verfolgen
Integration mit Firebase-Analytik-Dashboards
Hauptmerkmale
Automatische Absturzdetektion
Benutzerdefinierte Protokoll- und Metadatenunterstützung
Plattformübergreifende Kompatibilität von Android und iOS
Echtzeit-Crashberichterstattung
Integration mit dem Firebase Crashlytics-Dashboard
Geeignet für
Mobile-App-Entwickler, die Firebase verwenden
Teams, die sich auf die App-Reliabilität konzentrieren
Projekte, die Crash-Analyse erfordern
Entwickler, die Produktions-Grade-Flutter-Apps erstellen
Apps, die Fehlerverfolgung und Diagnose benötigen
Hinweise
Firebase-Projektsetup erforderlich
Beschränkt auf die Plattformen Android und iOS
Erforderliche korrekte Initialisierung beim App-Start
Kann auf einigen Geräten zusätzliche Berechtigungen erfordern
Benutzerdefinierte Protokolle sollten sparsam verwendet werden, um Datenüberlastung zu vermeiden
Original-README
Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.
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.