Force a crash to test your implementation
You don't have to wait for a crash to know that Crashlytics is working. You
can add a button to your app's MainActivity
to force a crash:
Java
Button crashButton = new Button(this); crashButton.setText("Crash!"); crashButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Crashlytics.getInstance().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 { Crashlytics.getInstance().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.
Crashlytics 2.9.6 +
To enable debug logging on your development device, set two adb shell flags before running your app:
adb shell setprop log.tag.Fabric DEBUG adb shell setprop log.tag.CrashlyticsCore DEBUG
View the logs in the device logs by running:
adb logcat -s Fabric CrashlyticsCore
To disable debug mode, set the flags back to INFO.
adb shell setprop log.tag.Fabric INFO adb shell setprop log.tag.CrashlyticsCore INFO
Previous Versions
To enable debug mode on Android, you first need to disable automatic initialization by adding a
line to your AndroidManifest.xml
:
<meta-data android:name="firebase_crashlytics_collection_enabled" android:value="false" />
You can then manually initialize Crashlytics with the debugger enabled:
Java
final Fabric fabric = new Fabric.Builder(this) .kits(new Crashlytics()) .debuggable(true) // Enables Crashlytics debugger .build(); Fabric.with(fabric);
Kotlin+KTX
val fabric = Fabric.Builder(this) .kits(Crashlytics()) .debuggable(true) // Enables Crashlytics debugger .build() Fabric.with(fabric)
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.