How to disable Crashlytics during development

Marc from Crashlytics here. Here's a couple of ways to disable Crashlytics while you are doing your debug builds!

  1. Use a different android:versionString for debug and release builds and then disable crash reporting from the Crashlytics web dashboard for the debug version.

  2. Wrap the call to Crashlytics.start() in an if statement that checks a debug flag. You could use either a custom flag or an approach like the ones proposed here: How to check if APK is signed or "debug build"?


I found the solution from Crashlytics (with Fabric integration)

Put following code inside your Application class onCreate()

Crashlytics crashlytics = new Crashlytics.Builder().disabled(BuildConfig.DEBUG).build();
Fabric.with(this, crashlytics);

EDIT:

In Crashalitics 2.3 and above, this is deprecated. The correct code is:

CrashlyticsCore core = new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build();
Fabric.with(this, new Crashlytics.Builder().core(core).build());

or

Fabric.with(this, new Crashlytics.Builder().core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()).build());

(copied from Crashlytics deprecated method disabled())


EDIT2:

You can also optionally add this to your buildType in gradle. This command disables sending the crashlytics mapping file and generating an ID for each build, which speeds up gradle builds of those flavors. (It doesn't disable Crashlytics at run time.) See Mike B's answer here.

buildTypes {
    release {
           ....
    }
    debug {
        ext.enableCrashlytics = false
    }
}