Android Crashlytics Log Exception Manually

October 4, 2018
The exception is caught, but still report to Crashlytics
try {
} catch (IOException e) {
Crashlytics.logException(new Exception("Test"));


If you disable Crashlytics, calling Crashlytics.logException or Crashlytics.getInstance will cause the following exception.

java.lang.IllegalStateException: Must Initialize Fabric before using singleton()

As of version 2.9.8, there is no way to check if Crashlytics is enabled/initialized or not. Write a wrapper function instead.

inline fun logException(e: Throwable, message: String? = null) {
    try {
        // Crashlytics.log(Log.ERROR, tag, message)
        if (message != null) {
    // java.lang.IllegalStateException: Must Initialize Fabric before using singleton() when Crashlytics is disabled
    catch (e: Exception) { }

NOTE: Exception log by Crashlytics.logException is marked as Non-fatals, where you need to adjust the Event type = "Non-fatals" filter to view them in Firebase Console - Crashlytics.

UPDATE 2019-08-29:

To prevent Crashlytics.logException from throwing exception when disabled, initialize with the following during application startup.

val crashlytics = Crashlytics.Builder()
Fabric.with(this, crashlytics)


This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.