Android mapping support

Upload your Android mapping files to Bugsnag.

Overview

If you are using ProGuard or DexGuard to shrink your app, this will cause method and class names to become obfuscated, which makes debugging harder as the original file names, line numbers, and method names are not available.

In order to replace the obfuscated data with a human-readable stack trace, Bugsnag can use a mapping file.

ProGuard or DexGuard

By default Android applications are shrunk/obfuscated using ProGuard which has been the primary Android optimizer for some time. It is possible to control the way that ProGuard operates by using ProGuard configuration files. DexGuard is the commercial sibling of Proguard for Android, and optimizes code using similar configuration files.

Gradle plugin

If you’re using Android Studio/Gradle to build your Android projects, the best way to send your mapping files to Bugsnag is to use the Bugsnag Android Gradle plugin.

Please note that you will need to set minifyEnabled to true, if you wish the gradle plugin to upload your mapping file automatically.

android {
  buildTypes {
    release {
      minifyEnabled true
    }
  }
}

By default, we’ll upload mapping files to upload.bugsnag.com, if you are using Bugsnag Enterprise, you can configure your upload endpoint in your app’s build.gradle as follows:

bugsnag {
    endpoint 'http://upload.bugsnag.example.com'
}

ProGuard settings

We use the line numbers of crashes to help with error grouping. You’ll need explicitly to tell ProGuard/DexGuard to not strip this information by adding the following line to your configuration:

-keepattributes LineNumberTable,SourceFile
-keep class com.bugsnag.android.NativeInterface { *; }
-keep class com.bugsnag.android.Breadcrumbs { *; }
-keep class com.bugsnag.android.Breadcrumbs$Breadcrumb { *; }
-keep class com.bugsnag.android.BreadcrumbType { *; }
-keep class com.bugsnag.android.Severity { *; }
-keep class com.bugsnag.android.ndk.BugsnagObserver { *; }

If you are using our Gradle plugin, this will automatically be added to your ProGuard/DexGuard config.

If you are using proguard-android-optimize.txt settings then Bugsnag will convert the stack traces to a human-readable format, but the original file names might not be available (class name will be used instead of file name in this case).

If the stack traces provided to Bugsnag do not contain a valid file then we will use the unqualified class name in place of the file name.

Manually uploading mapping files

In cases where you are not using Gradle, you’ll need to manually upload your mapping file to Bugsnag using our API. See the Android Mapping Upload API reference for more details.