Google is committed to advancing racial equity for Black communities. See how.

Test your Crashlytics implementation

Force a crash to test your implementation

You don't have to wait for a crash to know that Crashlytics is working. To force a crash, add a button to your app's MainActivity:

Java

Button crashButton = new Button(this);
crashButton.setText("Crash!");
crashButton.setOnClickListener(new View.OnClickListener() {
   public void onClick(View view) {
       throw new RuntimeException("Test Crash"); // Force a crash
   }
});

addContentView(crashButton, new ViewGroup.LayoutParams(
       ViewGroup.LayoutParams.MATCH_PARENT,
       ViewGroup.LayoutParams.WRAP_CONTENT));

Kotlin+KTX

val crashButton = Button(this)
crashButton.text = "Crash!"
crashButton.setOnClickListener {
   throw RuntimeException("Test Crash") // Force a crash
}

addContentView(crashButton, ViewGroup.LayoutParams(
       ViewGroup.LayoutParams.MATCH_PARENT,
       ViewGroup.LayoutParams.WRAP_CONTENT))

To test the implementation, press the button in your app to force the crash, then reopen your app so that Crashlytics can send the crash report to Firebase. It may take up to five minutes for the report to appear in the Firebase console.

Enable Crashlytics debug logging

If your forced crash didn't crash, crashed before you wanted it to, or you're experiencing some other issue with Crashlytics, you can enable Crashlytics debug logging to track down the problem.

To enable debug logging on your development device, set an adb shell flag before running your app:

adb shell setprop log.tag.FirebaseCrashlytics DEBUG

To view the logs in your device logs, run:

adb logcat -s FirebaseCrashlytics

To disable debug logging, set the flag back to INFO:

adb shell setprop log.tag.FirebaseCrashlytics INFO

Next steps

  • Customize crash reports— Crashlytics automatically starts collecting crash reports as soon as you add the SDK, but you can also customize your setup by adding opt-in reporting, logs, keys, and even tracking of non-fatal errors.