Skip to content

Commit

Permalink
chore(android): Add missing gradle configuration options (#8301)
Browse files Browse the repository at this point in the history
Co-authored-by: Liza Mock <[email protected]>
Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Oct 20, 2023
1 parent fea8f41 commit c5fe5e4
Showing 1 changed file with 63 additions and 5 deletions.
68 changes: 63 additions & 5 deletions src/platforms/android/configuration/gradle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,42 @@ The `io.sentry.android.gradle` >= `3.0.0` requires [Android Gradle Plugin >= 7.0

### Configure

Set the auth token as an environment variable to be used when running your release build.

<OrgAuthTokenNote />

```bash
export SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
```

We expose the following configuration values directly in your `app/build.gradle`:

<SignInNote />

```groovy
import io.sentry.android.gradle.extensions.InstrumentationFeature
import io.sentry.android.gradle.instrumentation.logcat.LogcatLevel
sentry {
// Disables or enables debug log output, e.g. for for sentry-cli.
// Default is disabled.
debug = false
// The slug of the Sentry organization to use for uploading proguard mappings/source contexts.
org = "___ORG_SLUG___"
// The slug of the Sentry project to use for uploading proguard mappings/source contexts.
project = "___PROJECT_SLUG___"
// The authentication token to use for uploading proguard mappings/source contexts.
// WARNING: Do not expose this token in your build.gradle files, but rather set an environment
// variable and read it into this property.
authToken = System.getenv("SENTRY_AUTH_TOKEN")
// The url of your Sentry instance. If you're using SAAS (not self hosting) you do not have to
// set this. If you are self hosting you can set your URL here
url = null
// Disables or enables the handling of Proguard mapping for Sentry.
// If enabled the plugin will generate a UUID and will take care of
// uploading the mapping to Sentry. If disabled, all the logic
Expand Down Expand Up @@ -93,6 +122,12 @@ sentry {
// code as part of your stack traces in Sentry.
includeSourceContext = false
// Configure additional directories to be included in the source bundle which is used for
// source context. The directories should be specified relative to the Gradle module/project's
// root. For example, if you have a custom source set alongside 'main', the parameter would be
// 'src/custom/java'.
additionalSourceDirsForSourceContext = []
// Enable or disable the tracing instrumentation.
// Does auto instrumentation for specified features through bytecode manipulation.
// Default is enabled.
Expand Down Expand Up @@ -146,6 +181,25 @@ sentry {
import io.sentry.android.gradle.extensions.InstrumentationFeature

sentry {
// Disables or enables debug log output, e.g. for for sentry-cli.
// Default is disabled.
debug.set(false)

// The slug of the Sentry organization to use for uploading proguard mappings/source contexts.
org.set("___ORG_SLUG___")

// The slug of the Sentry project to use for uploading proguard mappings/source contexts.
project.set("___PROJECT_SLUG___")

// The authentication token to use for uploading proguard mappings/source contexts.
// WARNING: Do not expose this token in your build.gradle files, but rather set an environment
// variable and read it into this property.
authToken.set(System.getenv("SENTRY_AUTH_TOKEN"))

// The url of your Sentry instance. If you're using SAAS (not self hosting) you do not have to
// set this. If you are self hosting you can set your URL here
url = null

// Disables or enables the handling of Proguard mapping for Sentry.
// If enabled the plugin will generate a UUID and will take care of
// uploading the mapping to Sentry. If disabled, all the logic
Expand Down Expand Up @@ -186,6 +240,12 @@ sentry {
// code as part of your stack traces in Sentry.
includeSourceContext.set(false)

// Configure additional directories to be included in the source bundle which is used for
// source context. The directories should be specified relative to the Gradle module/project's
// root. For example, if you have a custom source set alongside 'main', the parameter would be
// 'src/custom/java'.
additionalSourceDirsForSourceContext.set(emptySet())

// Enable or disable the tracing instrumentation.
// Does auto instrumentation for specified features through bytecode manipulation.
// Default is enabled.
Expand Down Expand Up @@ -260,13 +320,11 @@ sentry {

## ProGuard/R8 & DexGuard

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 through environment variables or from a `sentry.properties` file in your project root.
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 as long as you've enabled ProGuard/R8. The credentials for the upload step are defined in the Gradle extension above or loaded from a `sentry.properties` file in your project.

If you are using the Guardsquare's ProGuard or DexGuard tooling, you have to enable the `experimentalGuardsquareSupport` flag.
To use Guardsquare's ProGuard or DexGuard tooling, you'll have to enable the `experimentalGuardsquareSupport` flag. Learn more in the [full sentry-cli documentation](/product/cli/configuration/#configuration-values).

Learn more in the [full sentry-cli documentation](/product/cli/configuration/#configuration-values).

At the very minimum, you will need something similar to:
Instead of providing your credentials via the Gradle extension, you can create a `sentry.properties` file with the following content under your `app` module:

<OrgAuthTokenNote />

Expand Down

1 comment on commit c5fe5e4

@vercel
Copy link

@vercel vercel bot commented on c5fe5e4 Oct 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sentry-docs – ./

docs.sentry.io
sentry-docs-git-master.sentry.dev
sentry-docs.sentry.dev

Please sign in to comment.