Crashlytics deprecated method disabled()
Asked Answered
P

2

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?

Proleg answered 27/5, 2015 at 16:47 Comment(0)
E
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.

Evulsion answered 27/5, 2015 at 17:45 Comment(16)
Perfect! I wish there was better documentation where I could have found this.Proleg
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 implementedUnrighteous
@jmrmb80 try using Crashytics 2.3.0 and let me know if that works!Evulsion
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());Diaphony
Is this redundant if we disable crashlytics in gradle via the documentation that suggests adding ext.enableCrashlytics = false to the flavor?Maul
@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: #28339823Evulsion
@MikeB how can we disable it at runtime?Ciri
Above code is not working, i am using com.crashlytics.sdk.android:crashlytics:2.3.2@aarCiri
@ShajeelAfzal you'd want to use something like this: #31992576Evulsion
@MikeBonnell, will this code disable it if it has already been enabled before? From what I see, 'Fabric.with()' returns a singleton that doesn't change if it has already been initialized.Salable
@HéctorJúdezSapena There isn't a "kill" switch for the SDK currently. Once enabled, Crashlytics continues to run until a session ends. You would need to restart the app to disable it once more.Evulsion
@MikeBonnell i did what you mentioned above. But I think its not working. I am still getting Crashlytics report upload complete: <alphanumeric>.clsTripe
@uday There have been many different comments, so it's a bit hard to follow along. Can you share more information about what you're using and what's not working?Evulsion
This is still sending crash reports on debug builds. Marc's answer might be convenient for this case but the project i am working on previous developer used crashlytics.logException method in a lot of places. I wish disabled method actually stop sending crash reports on debug builds.Corposant
@MikeBonnell There isn't a "kill" switch for the SDK currently. Once enabled, Crashlytics continues to run until a session ends. You would need to restart the app to disable it once more. Its an older comment, Is this Statement valid even now ? We can't Disable Fabric , if it is already enabled in a single session ?Himation
Correct, there have been no changes to the SDK on this.Evulsion
W
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

Waggle answered 24/6, 2020 at 8:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.