Get deobfuscated crash reports with the Firebase Crashlytics SDK

The Crashlytics Gradle plugin can automatically detect when you obfuscate your code. When your build generates a mapping file, the plugin uploads it so the Crashlytics servers can use the file to render your app's stack traces as unobfuscated and human-readable code. Crashlytics can deobfuscate with any ProGuard-compatible mapping file, and has additionally been tested with ProGuard, R8, and DexGuard.

To preserve the information Crashlytics requires for producing readable crash reports, add the following lines to your Proguard or Dexguard config file:

-keepattributes SourceFile,LineNumberTable        # Keep file names and line numbers.
-keep public class * extends java.lang.Exception  # Optional: Keep custom exceptions.

To get help for questions or issues related to DexGuard, contact the Guardsquare support team directly. For help with ProGuard, visit the Guardsquare Community forums to get assistance from an expert.

Keep obfuscated build variants

To prevent the Crashlytics Gradle plugin from uploading the mapping file for variants that use obfuscation, set the firebaseCrashlytics.enableMappingFileUpload Gradle extension property to false in your app-level build.gradle file. This can help speed up build times for obfuscated builds, but note that resulting stack traces will appear obfuscated in the Crashlytics page of the Firebase console.

android {

  // To enable Crashlytics mapping file upload for specific build types:
  buildTypes {
    debug {
      minifyEnabled true
      firebaseCrashlytics {
        mappingFileUploadEnabled false
      }
    }
  }

  ...

  // To enable Crashlytics mapping file upload for specific product flavors:
  flavorDimensions "environment"
  productFlavors {
    staging {
      dimension "environment"
      ...
      firebaseCrashlytics {
        mappingFileUploadEnabled false
      }
    }
    prod {
      dimension "environment"
      ...
      firebaseCrashlytics {
        mappingFileUploadEnabled true
      }
    }
  }
}