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

你说的曾经没有我的故事 提交于 2019-12-03 11:30:29

问题


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

回答1:


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.




回答2:


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}" />



回答3:


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


来源:https://stackoverflow.com/questions/46878499/cant-disable-crashlytics-in-a-firebase-app-anymore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!