21

When using Crashlytics + Fabric for Android there is a really easy way to enable and disable crash reporting. I use it so during development and testing there aren't a ton of crashes alerting everyone.

Crashlytics crashlytics = new Crashlytics.Builder().disabled(true).build();

The disabled(boolean) method is now deprecated. Does anyone know what the replacement is for disabling and enabling crashlytics programmatically?

2 Answers 2

60

Mike from Crashlytics and Fabric here.

Here's what you want to use depending on your preference:

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());

See CrashlyticsCore.Builder#disabled documentation.

17
  • 3
    Perfect! I wish there was better documentation where I could have found this. May 27, 2015 at 20:07
  • Mike , does the second line have to read this way: Fabric.with(this, new Crashlytics.Builder().core(core).build(), new Crashlytics()); If not then I keep receiving the following error in the stacktrace when the app launches E/Fabric﹕ Error performing auto configuration. java.util.concurrent.ExecutionException: java.lang.IncompatibleClassChangeError: interface not implemented
    – joelreeves
    May 28, 2015 at 22:08
  • 1
    The Android Studio plugin keeps correcting it? Fabric.with(this, new Crashlytics.Builder().core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()).build()); >> Fabric.with(this, new Crashlytics.Builder().core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()).build(), new Crashlytics());
    – TomCB
    Jun 12, 2015 at 14:14
  • 1
    Is this redundant if we disable crashlytics in gradle via the documentation that suggests adding ext.enableCrashlytics = false to the flavor?
    – gMale
    Jul 16, 2015 at 20:56
  • 3
    @gmale that command disables Crashlytics from being built as part of your Gradle build flow. It doesn't disable Crashlytics at run time. See my answer here: stackoverflow.com/questions/28339323/… Jul 17, 2015 at 12:37
1

The Fabric Crashlytics SDK is now deprecated and FirebaseCrashlytics should be used

// Explicit initialization of Crashlytics is no longer required.
// OPTIONAL: If crash reporting has been explicitly disabled previously, add:
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(!BuildConfig.DEBUG);

See the migration documentation here

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.