From c5fe5e43bc5b3b6de6db9e450da226899ebe8aac Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Fri, 20 Oct 2023 12:25:17 +0200 Subject: [PATCH] chore(android): Add missing gradle configuration options (#8301) Co-authored-by: Liza Mock Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com> --- .../android/configuration/gradle.mdx | 68 +++++++++++++++++-- 1 file changed, 63 insertions(+), 5 deletions(-) diff --git a/src/platforms/android/configuration/gradle.mdx b/src/platforms/android/configuration/gradle.mdx index ef1914b8f5f36..a7e18c14dbc54 100644 --- a/src/platforms/android/configuration/gradle.mdx +++ b/src/platforms/android/configuration/gradle.mdx @@ -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. + + + +```bash +export SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___ +``` + We expose the following configuration values directly in your `app/build.gradle`: + + ```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 @@ -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. @@ -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 @@ -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. @@ -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: