Proper way to initialize Fabric.io for debugging/release

2.6k views Asked by At

Just a quick question about Crashlytics from Fabric.io:

To disable it in debug, should we still use:

 Crashlytics crashlytics = new Crashlytics.Builder().disabled(BuildConfig.DEBUG).build();
        Fabric.with(this, crashlytics);

Or does Fabric handle the debug/release difference and should we just use:

Fabric.with(this, new Crashlytics());

The disabled method is depricated and if you use the Fabric plugin in Android Studio, it always changes the crashlytics instance to new Crashlytics().

3

There are 3 answers

3
Gabriele Mariotti On BEST ANSWER

With the new 2.3.+ version you should use somenthing like this:

Fabric.with(this, new Crashlytics.Builder()
            .core(new CrashlyticsCore.Builder()
                    .disabled(BuildConfig.DEBUG)
                    .build())
            .build());
0
Bharatesh On

Try this.

Fabric.Builder.debuggable(boolean)

Java Doc API Crashlytics

setDebugMode(boolean debug) Deprecated. use Fabric.Builder.debuggable(boolean) instead

UPDATED

For more info visit SO - CrashLytics Deprecated

0
Ghedeon On

Another option would be to have a debug version of Application: https://www.littlerobots.nl/blog/stetho-for-android-debug-builds-only/

Basically, you'd need to have a debug version of your Application in the debug folder, with a debuggable version of Fabric, alongside with the manifest file, that is going to address your DebugApp:

<manifest
    package="com.mycompany"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <application
        tools:replace="android:name"
        android:name=".DebugApp"/>

</manifest>