Felix Eder
Felix Eder

Reputation: 325

How to disable Crashlytics in Android Studio Emulator

I'm developing an Android app and use Crashlytics to get crash-logs. This works very well when I install the APK on other devices as I can't get a stack trace in any other way.

The issue I'm having is that I'm constantly crashing the app in the emulator in Android Studio while developing. These crashes are also reported by Crashlytics, but I would like to disable them as it makes my Crashlytics Dashboard a bit messy as I do not know which crashes are made when developing and which are actual issues on released APK:s on other devices.

How can I make this happen?

Upvotes: 3

Views: 2052

Answers (2)

scottt
scottt

Reputation: 8381

Here's a way to disable Crashlytics reporting when running on an emulator or virtual box, but always enable it, even for debug builds, when running on real devices:

if (Build.PRODUCT.startsWith("sdk") || Build.PRODUCT.startsWith("vbox")) {
    Log.i(LOG_TAG, "Disabling Crashlytics reporting");
    CrashlyticsCore disabled = new CrashlyticsCore.Builder().disabled(true).build();
    Fabric.with(getApplication(), new Crashlytics.Builder().core(disabled).build());
} else {
    Log.i(LOG_TAG, "Enabling Crashlytics reporting");
    Fabric.with(getApplication(), new Crashlytics());
}

Upvotes: 3

John O'Reilly
John O'Reilly

Reputation: 10350

Following should disable Crashlytics if it's debug build (you can use other filters here if needed)

    if (BuildConfig.DEBUG) {
        CrashlyticsCore disableCrashlytics = new CrashlyticsCore.Builder().disabled(true).build();
        Fabric.with(getApplication(), new Crashlytics.Builder()
                .core(disableCrashlytics)
                .build());
     }

Upvotes: 3

Related Questions