Configure ProGuard and DexGuard

We’ve made it simple to set up ProGuard or DexGuard in your app and receive deobfuscated crash reports. First of all, Fabric uses annotations internally, so add the following line to your configuration file:

-keepattributes *Annotation*

Next, in order to provide the most meaningful crash reports, add the following line to your configuration file:

-keepattributes SourceFile,LineNumberTable

Crashlytics will still function without this rule, but your crash reports will not include proper file names or line numbers.

If you are using custom exceptions, add this line so that custom exception types are skipped during obfuscation:

-keep public class * extends java.lang.Exception

For Fabric to properly de-obfuscate your crash reports, you need to remove this line from your configuration file, or we won’t be able to automatically upload your mapping file:

-printmapping mapping.txt

Exclude Crashlytics with ProGuard

To skip running ProGuard on Crashlytics, just add the following to your ProGuard config file.

-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**

This will help speed up your builds so that you can ship and test even faster.

If you’re using a build tool, check out the following sections.

Ant

Crashlytics extends your standard Ant tasks to manage uploading ProGuard mappings file. Quickly set up your project by following these steps. If your ant build differs significantly from those provided with the Android SDK, please refer to the comments at the top of the crashlytics_build.xml file.

Using DexGuard? Add these two lines to custom_rules.xml of DexGuard.

<property name="proguard.enabled" value="true"/>
<import file="/dev_app/crashlytics-devtools/crashlytics_build.xml"/>

Maven

If you’ve already configured Maven, you’re all set. If ProGuard is configured to put the mappings file somewhere other than target/proguard_map.txt, just use this configuration option for the plugin to specify the location:

<configuration>
    <mapping_location>MAPPINGS_FILE_LOCATION</mapping_location>
</configuration>

Gradle

Once Gradle is configured, ensure that minifyEnabled=true is set in any flavor you’re using Crashlytics in. Crashlytics automatically uploads the mapping files for reach of your build variants.

Using DexGuard? Just add: apply plugin: 'io.fabric' after the DexGuard and Android plugins are applied.