How do I force a crash using the Android SDK?

This page is now deprecated. For the latest version, please click here.

Forcing a crash is a great way to test out the SDK!

How to force a crash

To cause a crash just throw an uncaught exception!

    throw new RuntimeException("This is a crash");

  1. Add the above line of code at some point after you've called Crashlytics.start();. A button action is a great place to start.
  2. Next, compile, build, and run your app.
  3. Force the crash by pressing the button you attached the crash code to and then relaunch the app.

Advanced

If you'd like to see other kinds of crashes, you can experiment!

Everyone loves a stack overflow:

    public void stackOverflow() {

        this.stackOverflow();     }

Keep in mind that exceptions are not guaranteed to cause a crash.   The full code path, including code in system libraries matters here. Devices and emulators and different OSes will have different behaviors regarding which types of errors actually cause crashes, especially when the UI thread is involved.

Feedback and Knowledge Base