Search code examples
firebasecrashlyticscrashlytics-android

Can't disable Crashlytics in a Firebase app (anymore)


After upgrading to com.crashlytics.sdk.android:crashlytics:2.7.1@aar (from 2.6.8), I can't disable Crashlytics anymore in my Firebase app.

Looks like there's some code in Crashlytics library itself that initializes Fabric with Crashlytics kit enabled whenever it detects that it's running inside a Firebase application. Indeed initializing with Crashlytics enabled and with ext.enableCrashlytics = false throws an UnmetDependencyException and crashes the app at startup (in fact, before my code in Application.onCreate runs).

Does anyone know a workaround for that? Sticking with 2.6.8 works for now. This is what I have in my code that used to work until an upgrade:

app/build.gradle:

ext.enableCrashlytics = false

Application.java (onCreate, full method body as requested):

super.onCreate();
if (LeakCanary.isInAnalyzerProcess(this)) {
    return;
}
LeakCanary.install(this);
// First Fabric invocation
Fabric.with(this, new Crashlytics.Builder().core(
    new CrashlyticsCore.Builder().disabled(true).build()).build());
RxJavaPlugins.setErrorHandler(e -> LOGGER.error("Undeliverable RxJava error", e));
// First Firebase invocation
FirebaseDatabase db = FirebaseDatabase.getInstance();
if (BuildConfig.DEBUG) {
    db.setLogLevel(com.google.firebase.database.Logger.Level.DEBUG);
}
db.setPersistenceEnabled(true);

Solution

  • Mike from Fabric here. Use:

    <meta-data android:name="firebase_crashlytics_collection_enabled" android:value="false" />
    

    if you want to disable Crashlytics while using Firebase.