Stay organized with collectionsSave and categorize content based on your preferences.
This quickstart describes how to set upFirebase Crashlyticsin your app
with theCrashlyticsFlutter plugin so that you can get comprehensive crash
reports in theFirebaseconsole.
Setting upCrashlyticsinvolves using both a command-line tool and your IDE.
To finish setup, you'll need to force a test exception to be thrown to send your
first crash report to Firebase.
Recommended: To automatically getbreadcrumb logsto understand user actions leading up to a crash, non-fatal, or ANR event,
you need to enableGoogle Analyticsin your Firebase project.
If your existing Firebase project doesn't haveGoogle Analyticsenabled, you can enableGoogle Analyticsfrom theIntegrationstabof yoursettings>Project settingsin theFirebaseconsole.
If you're creating a new Firebase project, enableGoogle Analyticsduring the project creation workflow.
Note that breadcrumb logs are available for all Android and Apple platforms
supported byCrashlytics(except watchOS).
Step 1: AddCrashlyticsto your Flutter project
From the root of your Flutter project, run the following command to install
the Flutter plugin forCrashlytics.
From the root directory of your Flutter project, run the following command:
flutterfireconfigure
Running this command ensures that your Flutter app's Firebase configuration
is up-to-date and, for Android, adds the requiredCrashlyticsGradle
plugin to your app.
Once complete, rebuild your Flutter project:
flutterrun
(Optional)If your Flutter project uses the--split-debug-infoflag
(and, optionally, also the--obfuscateflag), additional steps are
required to show readable stack traces for your apps.
Apple platforms:Make sure that your project is using the recommended
version configuration (Flutter 3.12.0+ andCrashlyticsFlutter plugin 3.3.4+) so that your project can
automatically generate and upload Flutter symbols (dSYM files) toCrashlytics.
Android:Use theFirebaseCLI(v.11.9.0+) to upload
Flutter debug symbols. You need to upload the debug symbolsbeforereporting a crash from an obfuscated code build.
From the root directory of your Flutter project, run the following
command:
FIREBASE_APP_ID: Your Firebase Android App ID (not your
package name) Example Firebase Android App ID:1:567383003300:android:17104a2ced0c9b9b
Need to find your Firebase App ID?
Here are two ways to find your Firebase App ID:
In yourgoogle-services.jsonfile, your App ID is themobilesdk_app_idvalue; or
In theFirebaseconsole, go to yourProject settings.
Scroll down to theYour appscard, then click on the desired Firebase
App to find its App ID.
PATH/TO/symbols: The same directory that you
pass to the--split-debug-infoflag when building the application
Step 2: Configure crash handlers
You can automatically catch all errors that are thrown within the Flutter
framework by overridingFlutterError.onErrorwithFirebaseCrashlytics.instance.recordFlutterFatalError:
voidmain()async{WidgetsFlutterBinding.ensureInitialized();awaitFirebase.initializeApp();// Pass all uncaught "fatal" errors from the framework to CrashlyticsFlutterError.onError=FirebaseCrashlytics.instance.recordFlutterFatalError;runApp(MyApp());}
To catch asynchronous errors that aren't handled by the Flutter framework, usePlatformDispatcher.instance.onError:
Future<void>main()async{WidgetsFlutterBinding.ensureInitialized();awaitFirebase.initializeApp();FlutterError.onError=(errorDetails){FirebaseCrashlytics.instance.recordFlutterFatalError(errorDetails);};// Pass all uncaught asynchronous errors that aren't handled by the Flutter framework to CrashlyticsPlatformDispatcher.instance.onError=(error,stack){FirebaseCrashlytics.instance.recordError(error,stack,fatal:true);returntrue;};runApp(MyApp());}
To finish setting upCrashlyticsand see initial data in theCrashlyticsdashboard of theFirebaseconsole, you need to force a test exception to be
thrown.
Add code to your app that you can use to force a test exception to be
thrown.
If you’ve added an error handler that callsFirebaseCrashlytics.instance.recordError(error, stack, fatal: true)to the
top-levelZone, you can use the following code to add a button to your app
that, when pressed, throws a test exception:
TextButton(onPressed:()=>throwException(),child:constText("Throw Test Exception"),),
Build and run your app.
Force the test exception to be thrown in order to send your app's first
report:
Open your app from your test device or emulator.
In your app, press the test exception button that you added using the
code above.
If you've refreshed the console and you're still not seeing the test crash
after five minutes,enable debug loggingto see if your app is sending crash reports.
And that's it!Crashlyticsis now monitoring your app for crashes and, on
Android, non-fatal errors and ANRs. Visit theCrashlyticsdashboardto view and investigate all your reports and statistics.
Integrate withGoogle Playso that you can filter your Android app's crash reports byGoogle Playtrack
directly in theCrashlyticsdashboard. This allows you to better focus
your dashboard on specific builds.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-11-15 UTC."],[],[]]