Force a crash to test your implementation
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 calls
FirebaseCrashlytics.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: () => throw Exception(), child: const Text("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.
Go to the Crashlytics dashboard of the Firebase console to see your test crash.
If you've refreshed the console and you're still not seeing the test crash after five minutes, try enabling debug logging (next section).
Enable debug logging for Crashlytics
If you don't see your test crash in the Crashlytics dashboard, you can use debug logging for Crashlytics to help track down the problem.
Apple platforms
Enable debug logging:
In Xcode, select Product > Scheme > Edit scheme.
Select Run from the left menu, then select the Arguments tab.
In the Arguments Passed on Launch section, add
-FIRDebugEnabled
.
Force a test crash. The first section on this page describes how to do this.
Within your logs, search for a log message from Crashlytics that contains the following string, which verifies that your app is sending crashes to Firebase.
Completed report submission
If you don't see this log or your test crash in the Crashlytics dashboard of the Firebase console after five minutes, reach out to Firebase Support with a copy of your log output so that we can help you troubleshoot further.
Android
Enable and view debug logging for Crashlytics:
Before running your app, set the following
adb
shell flag toDEBUG
:adb shell setprop log.tag.FirebaseCrashlytics DEBUG
View the logs in your device logs by running the following command:
adb logcat -s FirebaseCrashlytics
Force a test crash. The first section on this page describes how to do this.
Look for the following message or code
204
in your logcat output, either of which verifies that your app is sending crashes to Firebase.Crashlytics report upload complete
If you don't see this log or your test crash in the Crashlytics dashboard of the Firebase console after five minutes, reach out to Firebase Support with a copy of your log output so that we can help you troubleshoot further.
Next steps
- Customize your crash report setup by adding opt-in reporting, logs, keys, and tracking of non-fatal errors.