New Firebase Crashlytics disable in debug mode

To do it programmatically use below code in Application class

FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(!BuildConfig.DEBUG)
//enabled only for signed builds

Enable collection for select users by calling the Crashlytics data collection override at runtime. The override value persists across launches of your app so Crashlytics can automatically collect reports for future launches of that app instance. To opt out of automatic crash reporting, pass false as the override value. When set to false, the new value does not apply until the next run of the app.

Here is the link to documentation https://firebase.google.com/docs/crashlytics/customize-crash-reports?platform=android#enable-reporting


I have tried once some time ago which worked for me . Add this to build.gradle.

android {
  buildTypes {
     debug {
        manifestPlaceholders = [crashlyticsCollectionEnabled:"false"]
        ...
     }

    release {
        manifestPlaceholders = [crashlyticsCollectionEnabled:"true"]
        ...
    }
  }
}

And then set this attribute in manifest .

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

If you log manually also then you can use something like this at runtime :-

FirebaseCrashlytics.getInstance().recordException(RuntimeException("Invalidtoken"))

Also Check this out .