Force a Test Crash With Fabric
suggest changeAdd a button you can tap to trigger a crash. Paste this into the layout where the button should appear. layout_centerVertical and layout_centerHorizontal apply when the parent is a RelativeLayout.
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Force Crash!"
android:onClick="forceCrash"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
Throw a RuntimeException
public void forceCrash(View view) {
throw new RuntimeException("This is a crash");
}
Run the app and tap the button. After Crashlytics uploads the report, the crash appears on the dashboard and Crashlytics sends an email.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents