Test your Firebase Crashlytics implementation


Force a crash to test your implementation


You don't have to wait for a crash to know that Crashlytics is working. You can use the SDK to force a crash by adding the following code to your app:

#import "ViewController.h"
#import <Crashlytics/Crashlytics.h>

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

    UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = CGRectMake(20, 50, 100, 30);
    [button setTitle:@"Crash" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(crashButtonTapped:)
    [self.view addSubview:button];

- (IBAction)crashButtonTapped:(id)sender {
    [[Crashlytics sharedInstance] crash];

import UIKit
import Crashlytics

class ViewController: UIViewController {
    override func viewDidLoad() {

        // Do any additional setup after loading the view, typically from a nib.

        let button = UIButton(type: .roundedRect)
        button.frame = CGRect(x: 20, y: 50, width: 100, height: 30)
        button.setTitle("Crash", for: [])
        button.addTarget(self, action: #selector(self.crashButtonTapped(_:)), for: .touchUpInside)

    @IBAction func crashButtonTapped(_ sender: AnyObject) {

Adjust your project's debug settings

Crashlytics can’t capture crashes if your build attaches a debugger at launch. Adjust your build settings to change the project's debug information format:

  1. With your project still selected in the Xcode Navigator, open the Build Settings tab.
  2. Click All at the top of the tab to display all build settings.
  3. Search for "debug information format".
  4. Set the Debug Information Format setting to DWARF with dSYM File.

Test it out

The code snippet above adds a button that crashes your app when pressed. For it to work, run the app without a debugger:

  1. Click play_arrow Build and then run the current scheme in Xcode to build your app on a device or simulator.
  2. Click stop Stop running the scheme or action in Xcode to close the initial instance of your app. This initial instance includes a debugger that interferes with Crashlytics.
  3. Open your app again from the simulator or device.
  4. Touch Crash to crash the app.
  5. Open your app once more to let the Crashlytics API report the crash. Your crash should show up in the Firebase console within 5 minutes.

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:

Button crashButton = new Button(this);
crashButton.setOnClickListener(new View.OnClickListener() {
    public void onClick(View view) {
        Crashlytics.getInstance().crash(); // Force a crash
               new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,

When testing, reopen your app after pressing the button to crash it to make sure Crashlytics has a chance to report the crash. The report should appear in the Firebase console within five minutes.

Enable Crashlytics debug mode

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 mode to track down the problem.

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  // Initialize Firebase service.
  [FIRApp configure];
  [Fabric.sharedSDK setDebug:YES];
  return YES;
func application(_ application: UIApplication, didFinishLaunchingWithOptions
  launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  // Initialize Firebase service.
  Fabric.sharedSDK().debug = true
  return true

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:

final Fabric fabric = new Fabric.Builder(this)
        .kits(new Crashlytics())
        .debuggable(true)           // Enables Crashlytics debugger

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 non-fatal errors.

Send feedback about...

Need help? Visit our support page.