Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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);
like image 675
J. Williams Avatar asked Oct 22 '17 19:10

J. Williams


People also ask

How do I remove Crashlytics from Firebase?

If you want to disable data collection by default for all app runs, add the firebase_crashlytics_collection_enabled flag to your app's AndroidManifest.

Is Crashlytics deprecated?

Now that the Firebase Crashlytics SDK is publicly available, we are deprecating the legacy Fabric SDK. The Fabric SDK will continue reporting your app's crashes until November 15, 2020.

How do I disable Firebase Crashlytics in debug mode?

To opt out of automatic crash reporting, pass false as the override value. When set to false, the new value does not apply until the next run of the app. To disable the crash logs while in debug mode you must pass ! BuildConfig.


3 Answers

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}" />
like image 181
itzhar Avatar answered Oct 24 '22 05:10

itzhar


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.

like image 33
Mike Bonnell Avatar answered Oct 24 '22 04:10

Mike Bonnell


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)
   }
like image 45
Ninja420 Avatar answered Oct 24 '22 05:10

Ninja420