Android Disable Crashlytics in Debug Build

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

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.