Use Crashlytics within a product flavor in Android Studio

Had a similar problem: I had to turn off crashlytics’ reports in debug builds. Michael’s answer did not help me: crashlytics destroyed application on start after I added ext.enableCrashlytics = false to gradle configuration. Thanks to Github I found a working solutions:


android {
    buildTypes {
        debug {
            // enable crashlytics where you need
            buildConfigField "boolean", "USE_CRASHLYTICS", "false"
            ext.enableCrashlytics = false
// ...

and application class:

public void onCreate() {
    if ( BuildConfig.USE_CRASHLYTICS ) {


According to slott’s comment: with the Fabric you should use something like this:

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

Leave a Comment