ProGuard

To use ProGuard with Sentry, upload the ProGuard mapping files by using our Gradle integration (recommended) or manually by using sentry-cli.

Gradle

Using Gradle (Android Studio) in your app/build.gradle add:

app/build.gradle
Copied
apply plugin: 'io.sentry.android.gradle'

And declare a dependency in your top-level build.gradle:

build.gradle
Copied
buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        // https://github.com/getsentry/sentry-android-gradle-plugin/releases
        classpath 'io.sentry:sentry-android-gradle-plugin:{version}'
    }
}

The plugin will automatically generate appropriate ProGuard mapping files and upload them when you run gradle assemble{BuildVariant}. For example, assembleRelease — Release is the default, but the plugin works for others if you have enabled ProGuard/R8. The credentials for the upload step are loaded via environment variables or from a sentry.properties file in your project root.

For more information, see the full sentry-cli documentation.

At the very minimum you will need something like this:

Copied
defaults.project=your-project
defaults.org=your-org
auth.token=YOUR_AUTH_TOKEN

You can find your authentication token on the Sentry API page. For more information about the available configuration options, see the full sentry-cli documentation.

Gradle Configuration

Additionally, we expose a few configuration values directly in Gradle:

app/build.gradle
Copied
sentry {
    // Disables or enables the automatic configuration of ProGuard
    // for Sentry.  This injects a default config for ProGuard so
    // you don't need to do it manually.

    // Only enable it if you are using sentry-android <= v1.7,
    // sentry-android >= v2.0 already does it automatically.
    autoProguardConfig false

    // Enables or disables the automatic upload of mapping files
    // during a build.  If you disable this, you'll need to manually
    // upload the mapping files with sentry-cli when you do a release.
    autoUpload true

    // Disables or enables the automatic configuration of Native Symbols
    // for Sentry. This executes sentry-cli automatically so
    // you don't need to do it manually.
    // Default is disabled.
    uploadNativeSymbols false

    // Does or doesn't include the source code of native code for Sentry.
    // This executes sentry-cli with the --include-sources param. automatically so
    // you don't need to do it manually.
    // Default is disabled.
    includeNativeSources false
}

And that's it! Now when you build your app, the plugin will upload the ProGuard/R8 mappings, source bundle, and native symbols, as you configured them to Sentry.

You can edit this page on GitHub.