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);
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.
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}" />
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