Fabric's Crashlytics with Firebase can't be disabled for DEBUG builds

Correct answers have been posted by Bob Snyder and niqueco already however it seems kinda tedious to change the meta-data value every time you are building an actual release APK thus here's a solution that uses so called manifestPlaceholder and changes the value automatically to trueor false depending on the buildType.

Add the following to your apps build.gradle

android {

    // ...

    buildTypes {
        debug {
            manifestPlaceholders = [enableCrashReporting:"false"]
        }
        release {
            manifestPlaceholders = [enableCrashReporting:"true"]
        }
    }

}

And this to your AndroidManifest.xml

<manifest ... >

    <application ...>

        // ...

        <meta-data android:name="firebase_crashlytics_collection_enabled" android:value="${enableCrashReporting}" />

    </application>

</manifest>

You can verify the current value by clicking on the Merged Manifest tab once you have opened the AndroidManifest.xml. You should see something like this:

Merged manifest meta-data value for crash reporting


The Firebase Crashlytics documentation explains that once reporting is enabled in an app session, it cannot be disabled.

By default, Crashlytics reporting is enabled in a ContentProvider named CrashlyticsInitProvider that executes before your Application instance is created. CrashlyticsInitProvider enables or disables reporting based on the meta-data value firebase_crashlytics_collection_enabled, which by default is true.

If you want reporting disabled, it's critical that the manifest meta-data be present and set to false:

<meta-data
    android:name="firebase_crashlytics_collection_enabled"
    android:value="false" />

Look in the logcat during app initialization for the message:

CrashlyticsInitProvider: CrashlyticsInitProvider initialization successful

If the message is present, firebase_crashlytics_collection_enabled is true. If the message is not present, you have successfully set the meta-data to disable crash reporting.

If the meta-data is missing or set to true, you cannot disable reporting in your code using a call to Fabric.with(...).

In a comment to another answer, you indicate that you tried disabling reporting using the meta-data and were not successful. Check for a typo and ensure the declaration is correctly placed in the <application> element. In my tests, I am able to disabling reporting using the meta-data and then enable at run time.


I've finally found the issue. Crashlytics is initialized from a content provider, so by the time you try to disable from Application's onCreate() it's too late. Going through the decompiled code I've seen that you can disable that initialization by adding metadata to the <application> element in the manifest.

So, what I do is this... I've added this to app/src/debug/AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?><!--suppress ALL -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="<your app package>">

   <application>
           <meta-data android:name="firebase_crashlytics_collection_enabled" android:value="false" />
   </application>

</manifest>

I've also disabled Crashlytics in the app module gradle build file by adding:

    debug {
        ext.enableCrashlytics = false
    }

To my surprise I didn't need to do the Fabric.with(...) thing. The above was enough.

It's working fine: no reports.