J. Williams
J. Williams

Reputation: 734

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

Upvotes: 16

Views: 5987

Answers (3)

Ninja420
Ninja420

Reputation: 3872

Along with mikes above answer,

If you are setting firebase crash properties somewhere in your code, make sure that you don't set them for debug code, otherwise you might notice strange behaviour for the app.

   if (!BuildConfig.DEBUG) {
       Crashlytics.setUserIdentifier(DataStore.storeId)
   }

Upvotes: 1

itzhar
itzhar

Reputation: 13031

according to mike answer, im add my code:

Gradle:

buildTypes {
   release {
        manifestPlaceholders = [crashlyticsEnabled: true]
    }

    debug {
        manifestPlaceholders = [crashlyticsEnabled: false]
    }
}

Manifest.xml:

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

Upvotes: 35

Mike Bonnell
Mike Bonnell

Reputation: 16249

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.

Upvotes: 23

Related Questions