ProGuard
If you want to see de-obfuscated stack traces, you'll need to use ProGuard with Sentry. To do so, upload the ProGuard mapping files by either the recommended method of using our Gradle integration or manually by using sentry-cli.
The Android SDK ships with ProGuard rules automatically defined; no further configuration is needed.
The io.sentry.android.gradle
>= 3.0.0
requires Android Gradle Plugin >= 7.0.0.
Gradle
Using Gradle (Android Studio) in your app/build.gradle
add:
buildscript {
repositories {
mavenCentral()
}
}
plugins {
id "io.sentry.android.gradle" version "4.11.0"
}
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 similar to:
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 your app/build.gradle
:
sentry {
// 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.
// Default is enabled.
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
// Enable or disable the tracing instrumentation.
// Does auto instrumentation for 'androidx.sqlite' and 'androidx.room' libraries.
// It starts and finishes a Span within any CRUD operation.
// Default is enabled.
// Only available v3.0.0 and above.
tracingInstrumentation {
enabled = true
}
}
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.
Variant Filtering
You can specify which variant/flavor/build-type should be ignored by Sentry in your app/build.gradle
file:
sentry {
// List the build types that should be ignored (e.g. "release").
ignoredBuildTypes = ["release"]
// List the build flavors that should be ignored (e.g. "production").
ignoredFlavors = ["production"]
// List the build variant that should be ignored (e.g. "productionRelease").
ignoredVariants = ["productionRelease"]
}
- Package:
- maven:io.sentry:sentry-android
- Version:
- 7.13.0
- Repository:
- https://github.com/getsentry/sentry-java