Search code examples
androidfirebasecrashlyticsgoogle-fabriccrashlytics-android

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


I have an app that utilises Fabric's Crashlytics via Firebase. The following is the first thing executed in my Applications onCreate

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

Nonetheless, the crashes are submitted in DEBUG == true mode.

I use the following versions

in my build.gradle classpath "io.fabric.tools:gradle:1.25.1"

in my app/build.gradle implementation "com.crashlytics.sdk.android:crashlytics:2.9.1"

Unfortunately the crashes still get reported. Any ideas, what I am doing wrong?


Solution

  • 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.