Android Disable Crashlytics in Debug Build

December 16, 2019

Using the following setup, calling methods like Crashlytics.logException would not crash during debug.

Edit AndroidManifest.xml

<manifest ...>
    <application ...>
        <meta-data
            android:name="firebase_crashlytics_collection_enabled"
            android:value="false" />
    </application>
</manifest>

Edit module:app build.gradle.

android {
    ...

    buildTypes {
        debug {
            ext.enableCrashlytics = false
            ext.alwaysUpdateBuildId = false
        }
        release {
            ext.enableCrashlytics = true

            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

Edit Application

class LuaApp : Application() {
    override fun onCreate() {
        super.onCreate()

        val crashlytics = Crashlytics.Builder()
            .core(CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build())
            .build()
        Fabric.with(this, crashlytics)
    }
}
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.