From 03611874edd45b70c52c60146d9c2ff83b8f6060 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 10 Feb 2026 13:57:28 +0100 Subject: [PATCH 1/9] feat(android): Merge Manual Setup and Manual Configuration pages --- docs/platforms/android/manual-setup/index.mdx | 172 +++++++++++++++++- 1 file changed, 169 insertions(+), 3 deletions(-) diff --git a/docs/platforms/android/manual-setup/index.mdx b/docs/platforms/android/manual-setup/index.mdx index b2612b29ee75e5..45be5e1fa652c5 100644 --- a/docs/platforms/android/manual-setup/index.mdx +++ b/docs/platforms/android/manual-setup/index.mdx @@ -2,6 +2,8 @@ title: Manual Setup sidebar_order: 1 description: "Learn how to set up the SDK manually." +redirect_from: + - /platforms/android/configuration/manual-init/ --- If you can't (or prefer not to) run the [automatic setup](/platforms/android/#install), you can follow the instructions below to configure your application manually. @@ -26,7 +28,29 @@ plugins { Version `{{@inject packages.version('sentry.java.android.gradle-plugin', '3.0.0') }}` of the plugin will automatically add the Sentry Android SDK (version `{{@inject packages.version('sentry.java.android', '4.2.0') }}`) to your app. -## Configuration +### Manual Installation + +If you don't want the Sentry Gradle plugin to install the Sentry SDK automatically, you can define the dependency directly in the `build.gradle` file of your app module. + +```groovy {filename:app/build.gradle} +dependencies { + implementation 'io.sentry:sentry-android:{{@inject packages.version('sentry.java.android', '4.2.0') }}' +} +``` + +```kotlin {filename:app/build.gradle.kts} +dependencies { + implementation("io.sentry:sentry-android:{{@inject packages.version('sentry.java.android', '4.2.0') }}") +} +``` + + + +If you're using multiple Sentry dependencies, you can add a [bill of materials](/platforms/android/configuration/bill-of-materials) to avoid specifying the version of each dependency. + + + +## Configuration via AndroidManifest.xml Configuration is done via the application `AndroidManifest.xml`. Here's an example config which should get you started: @@ -39,7 +63,7 @@ Configuration is done via the application `AndroidManifest.xml`. Here's an examp - + @@ -68,6 +92,148 @@ Configuration is done via the application `AndroidManifest.xml`. Here's an examp Under the hood, Sentry uses a `ContentProvider` to initialize the SDK based on the values provided above. This way, the SDK can capture important crashes and metrics right from the app start. +## Configuration via SentryOptions + +Initialize the SDK manually when you need to provide additional configuration to the SDK that cannot be specified in the manifest. + +To initialize the SDK manually, disable the auto initialization. You can do so by adding the following line into your manifest: + +```xml {filename:AndroidManifest.xml} + + + +``` + +Or, to completely remove the merging of the `ContentProvider`: + +```xml {filename:AndroidManifest.xml} + + + + + +``` + +The next step is to initialize the SDK directly in your code. + +The SDK can catch errors and crashes only after you've initialized it. So, we recommend calling `SentryAndroid.init` in the instance your Application class right after the application is created. If you don't have a custom Application class yet, [checkout the official docs on how to create one](https://developer.android.com/reference/android/app/Application). + +Configuration options will be loaded from the manifest so that you don't need to have the static properties in your code. In the `init` method, you can provide a callback that will modify the configuration and also register new options. + + +```java +import io.sentry.ScreenshotStrategyType; +import io.sentry.SentryLevel; +import io.sentry.ProfileLifecycle; +import io.sentry.android.core.SentryAndroid; +import android.app.Application; + +public class MyApplication extends Application { + public void onCreate() { + super.onCreate(); + + SentryAndroid.init(this, options -> { + // Required: set your sentry.io project identifier (DSN) + options.setDsn("___PUBLIC_DSN___"); + // Add data like request headers, user ip address and device name, see https://docs.sentry.io/platforms/android/data-management/data-collected/ for more info + options.setSendDefaultPii(true); + // enable automatic traces for user interactions (clicks, swipes, scrolls) + options.setEnableUserInteractionTracing(true); + // enable screenshot for crashes + options.setAttachScreenshot(true); + // enable view hierarchy for crashes + options.setAttachViewHierarchy(true); + // enable the performance API by setting a sample-rate, adjust in production env + options.setTracesSampleRate(1.0); + // enable UI profiling, adjust in production env. This is evaluated only once per session + options.setProfileSessionSampleRate(1.0); + // set profiling mode. For more info see https://docs.sentry.io/platforms/android/profiling/#enabling-ui-profiling + options.setProfileLifecycle(ProfileLifecycle.TRACE); + // enable profiling on app start. The app start profile will be stopped automatically when the app start root span finishes + options.setStartProfilerOnAppStart(true); + // record session replays for 100% of errors and 10% of sessions + options.getSessionReplay().setSessionSampleRate(0.1); + options.getSessionReplay().setOnErrorSampleRate(1.0); + + // If your application has strict PII requirements we recommend using the Canvas screenshot strategy. + // See the Android Session Replay documentation for details: https://docs.sentry.io/platforms/android/session-replay/#screenshot-strategy. + // options.getSessionReplay().setScreenshotStrategy(ScreenshotStrategyType.CANVAS); + + + // Add a callback that will be used before the event is sent to Sentry. + // With this callback, you can modify the event or, when returning null, also discard the event. + options.setBeforeSend((event, hint) -> { + if (SentryLevel.DEBUG.equals(event.getLevel())) { + return null; + } else { + return event; + } + }); + }); + } +} +``` + +```kotlin +import io.sentry.ScreenshotStrategyType; +import io.sentry.SentryLevel; +import io.sentry.ProfileLifecycle; +import io.sentry.android.core.SentryAndroid; +import android.app.Application; +import io.sentry.SentryOptions + +class MyApplication : Application() { + override fun onCreate() { + super.onCreate() + + SentryAndroid.init(this) { options -> + // Required: set your sentry.io project identifier (DSN) + options.dsn = "___PUBLIC_DSN___" + // Add data like request headers, user ip address and device name, see https://docs.sentry.io/platforms/android/data-management/data-collected/ for more info + options.isSendDefaultPii = true + // enable automatic traces for user interactions (clicks, swipes, scrolls) + options.isEnableUserInteractionTracing = true + // enable screenshot for crashes + options.isAttachScreenshot = true + // enable view hierarchy for crashes + options.isAttachViewHierarchy = true + // enable the performance API by setting a sample-rate, adjust in production env + options.tracesSampleRate = 1.0 + // enable UI profiling, adjust in production env. This is evaluated only once per session + options.profileSessionSampleRate = 1.0 + // set profiling mode. For more info see https://docs.sentry.io/platforms/android/profiling/#enabling-ui-profiling + options.profileLifecycle = ProfileLifecycle.TRACE + // enable profiling on app start. The app start profile will be stopped automatically when the app start root span finishes + options.isStartProfilerOnAppStart = true + // record session replays for 100% of errors and 10% of sessions + options.sessionReplay.sessionSampleRate = 0.1 + options.sessionReplay.onErrorSampleRate = 1.0 + + // If your application has strict PII requirements we recommend using the Canvas screenshot strategy. + // See the Android Session Replay documentation for details: https://docs.sentry.io/platforms/android/session-replay/#screenshot-strategy. + // options.sessionReplay.screenshotStrategy = ScreenshotStrategyType.CANVAS + + // Add a callback that will be used before the event is sent to Sentry. + // With this callback, you can modify the event or, when returning null, also discard the event. + options.beforeSend = + SentryOptions.BeforeSendCallback { event, hint -> + if (SentryLevel.DEBUG == event.level) { + null + } else { + event + } + } + } + } +} +``` + + Additional options can be found on our dedicated options page. -If you want to customize the SDK init behaviour, you can still use the Manual Initialization method. From 060e11de5302b92fe25cccc8c177ac5c7e46ee47 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 10 Feb 2026 13:58:06 +0100 Subject: [PATCH 2/9] Drop old page --- .../android/configuration/manual-init.mdx | 113 ------------------ 1 file changed, 113 deletions(-) delete mode 100644 docs/platforms/android/configuration/manual-init.mdx diff --git a/docs/platforms/android/configuration/manual-init.mdx b/docs/platforms/android/configuration/manual-init.mdx deleted file mode 100644 index 14746fdac054c6..00000000000000 --- a/docs/platforms/android/configuration/manual-init.mdx +++ /dev/null @@ -1,113 +0,0 @@ ---- -title: Manual Configuration -sidebar_order: 20 -description: "Learn how to initialize the SDK manually when you need to provide additional configuration." ---- - -## Manual Installation - -If you don't want the Sentry Gradle plugin to install the Sentry SDK automatically, you can define the dependency directly in the `build.gradle` file of your app module. - -```groovy {filename:app/build.gradle} -dependencies { - implementation 'io.sentry:sentry-android:{{@inject packages.version('sentry.java.android', '4.2.0') }}' -} -``` - -```kotlin {filename:app/build.gradle.kts} -dependencies { - implementation("io.sentry:sentry-android:{{@inject packages.version('sentry.java.android', '4.2.0') }}") -} -``` - - - -The [NDK integration](/platforms/android/using-ndk/) comes packaged with the SDK and requires API level 16, though other levels are supported. If you're using multiple Sentry dependencies, you can add a [bill of materials](/platforms/android/configuration/bill-of-materials) to avoid specifying the version of each dependency. - - - -## Manual Initialization - -Initialize the SDK manually when you need to provide additional configuration to the SDK that cannot be specified in the manifest. - -To initialize the SDK manually, disable the auto initialization. You can do so by adding the following line into your manifest: - -```xml {filename:AndroidManifest.xml} - - - -``` - -Or, to completely remove the merging of the `ContentProvider`: - -```xml {filename:AndroidManifest.xml} - - - - - -``` - -The next step is to initialize the SDK directly in your code. - -The SDK can catch errors and crashes only after you've initialized it. So, we recommend calling `SentryAndroid.init` in the instance your Application class right after the application is created. If you don't have a custom Application class yet, [checkout the official docs on how to create one](https://developer.android.com/reference/android/app/Application). - -Configuration options will be loaded from the manifest so that you don't need to have the static properties in your code. In the `init` method, you can provide a callback that will modify the configuration and also register new options. - - -```java -import io.sentry.SentryLevel; -import io.sentry.android.core.SentryAndroid; -import android.app.Application; - -public class MyApplication extends Application { - public void onCreate() { - super.onCreate(); - - SentryAndroid.init(this, options -> { - options.setDsn("___PUBLIC_DSN___"); - // Add a callback that will be used before the event is sent to Sentry. - // With this callback, you can modify the event or, when returning null, also discard the event. - options.setBeforeSend((event, hint) -> { - if (SentryLevel.DEBUG.equals(event.getLevel())) - return null; - else - return event; - }); - }); - } -} -``` - -```kotlin -import io.sentry.android.core.SentryAndroid -import io.sentry.SentryOptions.BeforeSendCallback -import io.sentry.Hint -import android.app.Application - -class MyApplication : Application() { - override fun onCreate() { - super.onCreate() - - SentryAndroid.init(this) { options -> - options.dsn = "___PUBLIC_DSN___" - // Add a callback that will be used before the event is sent to Sentry. - // With this callback, you can modify the event or, when returning null, also discard the event. - options.beforeSend = - BeforeSendCallback { event: SentryEvent, hint: Hint -> - if (SentryLevel.DEBUG == event.level) { - null - } else { - event - } - } - } - } -} -``` From 3ad314ed779dc22eeafdd557c965b3268181683e Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 10 Feb 2026 14:07:10 +0100 Subject: [PATCH 3/9] update broken anchor links to renamed manual initialization section --- docs/platforms/android/integrations/apollo3/index.mdx | 2 +- docs/platforms/android/integrations/fragment/index.mdx | 2 +- docs/platforms/android/integrations/jetpack-compose/index.mdx | 4 ++-- docs/platforms/android/integrations/ktor-client/index.mdx | 2 +- docs/platforms/android/integrations/navigation/index.mdx | 2 +- docs/platforms/android/integrations/okhttp/index.mdx | 2 +- docs/platforms/android/integrations/timber/index.mdx | 2 +- docs/platforms/android/session-replay/configuration.mdx | 2 +- docs/platforms/android/troubleshooting/index.mdx | 2 +- docs/platforms/dart/guides/flutter/native-init.mdx | 2 +- docs/platforms/react-native/manual-setup/native-init.mdx | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/platforms/android/integrations/apollo3/index.mdx b/docs/platforms/android/integrations/apollo3/index.mdx index 07092588a5efa0..f349f0f22fd9d0 100644 --- a/docs/platforms/android/integrations/apollo3/index.mdx +++ b/docs/platforms/android/integrations/apollo3/index.mdx @@ -172,7 +172,7 @@ Alternatively, you can customize the event and scrub the data yourself. ### Customize or Drop the Error Event -To customize or drop the error event, you'll need to do a [manual initialization](/platforms/android/configuration/manual-init/#manual-initialization) of the Sentry Android SDK. The captured error event can then be customized or dropped with a `BeforeSendCallback`: +To customize or drop the error event, you'll need to do a [manual initialization](/platforms/android/manual-setup/#configuration-via-sentryoptions) of the Sentry Android SDK. The captured error event can then be customized or dropped with a `BeforeSendCallback`: ```kotlin import io.sentry.android.core.SentryAndroid diff --git a/docs/platforms/android/integrations/fragment/index.mdx b/docs/platforms/android/integrations/fragment/index.mdx index d8b97a81d7cebb..19f4336e73c821 100644 --- a/docs/platforms/android/integrations/fragment/index.mdx +++ b/docs/platforms/android/integrations/fragment/index.mdx @@ -42,7 +42,7 @@ However, you can still override the default behaviour by adding your own instanc ### Install -To add the Fragment integration, [manually initialize](/platforms/android/configuration/manual-init/#manual-initialization) the Android SDK, then add the `sentry-android-fragment` dependency. Using Gradle: +To add the Fragment integration, [manually initialize](/platforms/android/manual-setup/#configuration-via-sentryoptions) the Android SDK, then add the `sentry-android-fragment` dependency. Using Gradle: ```groovy implementation 'io.sentry:sentry-android:{{@inject packages.version('sentry.java.android', '5.1.0') }}' diff --git a/docs/platforms/android/integrations/jetpack-compose/index.mdx b/docs/platforms/android/integrations/jetpack-compose/index.mdx index 62d93d609505a2..1c1111f5ceb131 100644 --- a/docs/platforms/android/integrations/jetpack-compose/index.mdx +++ b/docs/platforms/android/integrations/jetpack-compose/index.mdx @@ -101,7 +101,7 @@ This feature is disabled by default, but you can enable it the following ways. #### Using `SentryOptions` -If you initialize the SDK [manually as mentioned here](/platforms/android/configuration/manual-init/#manual-initialization), you can enable user interactions like this: +If you initialize the SDK [manually as mentioned here](/platforms/android/manual-setup/#configuration-via-sentryoptions), you can enable user interactions like this: ```kotlin {filename:MyApplication.kt} SentryAndroid.init(this) { options -> @@ -330,7 +330,7 @@ fun Second() { ## Customize the Recorded Breadcrumb/Transaction -By default, the Navigation integration captures route arguments as additional data on breadcrumbs and transactions. In case the arguments contain any PII data, you can strip it out by way of `BeforeBreadcrumbCallback` and `EventProcessor` respectively. To do that, [manually initialize](/platforms/android/configuration/manual-init/#manual-initialization) the SDK and add the following snippet: +By default, the Navigation integration captures route arguments as additional data on breadcrumbs and transactions. In case the arguments contain any PII data, you can strip it out by way of `BeforeBreadcrumbCallback` and `EventProcessor` respectively. To do that, [manually initialize](/platforms/android/manual-setup/#configuration-via-sentryoptions) the SDK and add the following snippet: ```kotlin import io.sentry.EventProcessor diff --git a/docs/platforms/android/integrations/ktor-client/index.mdx b/docs/platforms/android/integrations/ktor-client/index.mdx index 5b667569dcff7c..8278b5ff0b4b7c 100644 --- a/docs/platforms/android/integrations/ktor-client/index.mdx +++ b/docs/platforms/android/integrations/ktor-client/index.mdx @@ -155,7 +155,7 @@ Those events are searchable and you can set alerts on them if you use the `http. ### Customize or Drop the Error Event -To customize or drop the error event, you need to do a [manual initialization](/platforms/android/configuration/manual-init/#manual-initialization) of the Sentry Android SDK. +To customize or drop the error event, you need to do a [manual initialization](/platforms/android/manual-setup/#configuration-via-sentryoptions) of the Sentry Android SDK. The captured error event can be customized or dropped with a `BeforeSendCallback`: diff --git a/docs/platforms/android/integrations/navigation/index.mdx b/docs/platforms/android/integrations/navigation/index.mdx index 8e2f4470345b13..9f0bf065ed00d7 100644 --- a/docs/platforms/android/integrations/navigation/index.mdx +++ b/docs/platforms/android/integrations/navigation/index.mdx @@ -123,7 +123,7 @@ class HomeFragment : Fragment() { ## Customize the Recorded Breadcrumb/Transaction -By default, the Navigation integration captures route arguments as additional data on breadcrumbs and transactions. In case the arguments contain any PII data, you can strip it out by way of `BeforeBreadcrumbCallback` and `EventProcessor` respectively. To do that, [manually initialize](/platforms/android/configuration/manual-init/#manual-initialization) the SDK and add the following snippet: +By default, the Navigation integration captures route arguments as additional data on breadcrumbs and transactions. In case the arguments contain any PII data, you can strip it out by way of `BeforeBreadcrumbCallback` and `EventProcessor` respectively. To do that, [manually initialize](/platforms/android/manual-setup/#configuration-via-sentryoptions) the SDK and add the following snippet: ```kotlin import io.sentry.EventProcessor diff --git a/docs/platforms/android/integrations/okhttp/index.mdx b/docs/platforms/android/integrations/okhttp/index.mdx index 8dd049424e68bc..48db2a30ef16e9 100644 --- a/docs/platforms/android/integrations/okhttp/index.mdx +++ b/docs/platforms/android/integrations/okhttp/index.mdx @@ -399,7 +399,7 @@ Those events are searchable and you can set alerts on them if you use the `http. ### Customize or Drop the Error Event -To customize or drop the error event, you need to do a [manual initialization](/platforms/android/configuration/manual-init/#manual-initialization) of the Sentry Android SDK. +To customize or drop the error event, you need to do a [manual initialization](/platforms/android/manual-setup/#configuration-via-sentryoptions) of the Sentry Android SDK. The captured error event can be customized or dropped with a `BeforeSendCallback`: diff --git a/docs/platforms/android/integrations/timber/index.mdx b/docs/platforms/android/integrations/timber/index.mdx index d3ee3137a8511d..8e94f0151694de 100644 --- a/docs/platforms/android/integrations/timber/index.mdx +++ b/docs/platforms/android/integrations/timber/index.mdx @@ -62,7 +62,7 @@ configurations.configureEach { ### Install -To add the Timber integration, [manually initialize](/platforms/android/configuration/manual-init/#manual-initialization) the Android SDK, then add the `sentry-android-timber` dependency. Using Gradle: +To add the Timber integration, [manually initialize](/platforms/android/manual-setup/#configuration-via-sentryoptions) the Android SDK, then add the `sentry-android-timber` dependency. Using Gradle: ```groovy implementation 'io.sentry:sentry-android:{{@inject packages.version('sentry.java.android', '4.2.0') }}' diff --git a/docs/platforms/android/session-replay/configuration.mdx b/docs/platforms/android/session-replay/configuration.mdx index 6fc337f7c0df23..2c8438b01e28dd 100644 --- a/docs/platforms/android/session-replay/configuration.mdx +++ b/docs/platforms/android/session-replay/configuration.mdx @@ -7,7 +7,7 @@ og_image: /og-images/platforms-android-session-replay-configuration.png ## General Configuration -On Android you configure Session Replay by creating `` entries inside your `AndroidManifest.xml` ([Options configuration](/platforms/android/configuration/options/)), or alternatively in code `SentryAndroid.init(context) { options -> ... }` ([Manual Initialization](/platforms/android/configuration/manual-init/#manual-initialization)). +On Android you configure Session Replay by creating `` entries inside your `AndroidManifest.xml` ([Options configuration](/platforms/android/configuration/options/)), or alternatively in code `SentryAndroid.init(context) { options -> ... }` ([Manual Initialization](/platforms/android/manual-setup/#configuration-via-sentryoptions)). The SDK exposes the following main options to configure Session Replay for your project: | Key | AndroidManifest | Type | Default | Description | diff --git a/docs/platforms/android/troubleshooting/index.mdx b/docs/platforms/android/troubleshooting/index.mdx index 67d658e2be5925..8eeb5f69dd406e 100644 --- a/docs/platforms/android/troubleshooting/index.mdx +++ b/docs/platforms/android/troubleshooting/index.mdx @@ -10,7 +10,7 @@ sidebar_section: configuration If stack traces don't get deobfuscated properly, even though mapping files are uploaded correctly, or if Android context information is missing from events, a possible reason is that the SDK is initialized with `Sentry.init` instead of `SentryAndroid.init`. -For manual initialization on Android, always use `SentryAndroid.init`. +For manual initialization on Android, always use `SentryAndroid.init`. From SDK version `8.0.0` on, using `Sentry.init` on Android will throw an `IllegalArgumentException`. diff --git a/docs/platforms/dart/guides/flutter/native-init.mdx b/docs/platforms/dart/guides/flutter/native-init.mdx index 1b8648ff932815..113e0de92c6273 100644 --- a/docs/platforms/dart/guides/flutter/native-init.mdx +++ b/docs/platforms/dart/guides/flutter/native-init.mdx @@ -18,7 +18,7 @@ This will prevent the Flutter SDK from initializing the native SDKs automaticall Next, initialize the native SDKs as specified in the guides below. -- [Android](/platforms/android/configuration/manual-init/#manual-initialization) +- [Android](/platforms/android/manual-setup/#configuration-via-sentryoptions) - [iOS](/platforms/apple/guides/ios/manual-setup/) - [Browser](/platforms/javascript/#configure) diff --git a/docs/platforms/react-native/manual-setup/native-init.mdx b/docs/platforms/react-native/manual-setup/native-init.mdx index 28f5693fe7b56b..2a63e94ebe9edf 100644 --- a/docs/platforms/react-native/manual-setup/native-init.mdx +++ b/docs/platforms/react-native/manual-setup/native-init.mdx @@ -52,4 +52,4 @@ To use auto-init, add the following to your `AndroidManifest.xml`: Then follow [the guide on initializing Android](/platforms/android/#configure). -If you want to manually initialize the Android SDK without using the content provider, you can then [follow the manual initialization guide](/platforms/android/configuration/manual-init/#manual-initialization) without needing to add the tag since `io.sentry.auto-init` is set to `false` by the React Native SDK. +If you want to manually initialize the Android SDK without using the content provider, you can then [follow the manual initialization guide](/platforms/android/manual-setup/#configuration-via-sentryoptions) without needing to add the tag since `io.sentry.auto-init` is set to `false` by the React Native SDK. From 4bb278c9035ad17a82423e21e686f0f697ee8f79 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 10 Feb 2026 15:10:16 +0100 Subject: [PATCH 4/9] Fix 404 --- platform-includes/configuration/config-intro/android.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform-includes/configuration/config-intro/android.mdx b/platform-includes/configuration/config-intro/android.mdx index e09f0579939d6d..438c69dc7a65d3 100644 --- a/platform-includes/configuration/config-intro/android.mdx +++ b/platform-includes/configuration/config-intro/android.mdx @@ -5,4 +5,4 @@ Options on Android can be set by setting the values on the `AndroidManifest.xml` ``` -Or, if you are manually instrumenting Sentry, follow the [Manual Initialization](/platforms/android/configuration/manual-init/#manual-initialization) configuration. +Or, if you are manually instrumenting Sentry, follow the [Manual Initialization](/platforms/android/manual-setup/#configuration-via-sentryoptions) configuration. From 93e3feec96c5fd8486ec426010f7be654dbc7090 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 10 Feb 2026 15:20:16 +0100 Subject: [PATCH 5/9] Add proper redirects --- docs/platforms/android/manual-setup/index.mdx | 2 -- src/middleware.ts | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/platforms/android/manual-setup/index.mdx b/docs/platforms/android/manual-setup/index.mdx index 45be5e1fa652c5..4162ba87f8f60b 100644 --- a/docs/platforms/android/manual-setup/index.mdx +++ b/docs/platforms/android/manual-setup/index.mdx @@ -2,8 +2,6 @@ title: Manual Setup sidebar_order: 1 description: "Learn how to set up the SDK manually." -redirect_from: - - /platforms/android/configuration/manual-init/ --- If you can't (or prefer not to) run the [automatic setup](/platforms/android/#install), you can follow the instructions below to configure your application manually. diff --git a/src/middleware.ts b/src/middleware.ts index 6bdd31c0040c40..81244187b789be 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -1022,7 +1022,11 @@ const USER_DOCS_REDIRECTS: Redirect[] = [ }, { from: '/platforms/android/manual-configuration/', - to: '/platforms/android/configuration/manual-init/', + to: '/platforms/android/manual-setup/', + }, + { + from: '/platforms/android/configuration/manual-init/', + to: '/platforms/android/manual-setup/', }, { from: '/platforms/android/advanced-usage/', From 70a28ce8b1d00a836707fe22e7fbb1a9c62b2d42 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 10 Feb 2026 18:11:06 +0100 Subject: [PATCH 6/9] Mention logs in the config too --- docs/platforms/android/manual-setup/index.mdx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/platforms/android/manual-setup/index.mdx b/docs/platforms/android/manual-setup/index.mdx index 4162ba87f8f60b..3ecfdabdb4075e 100644 --- a/docs/platforms/android/manual-setup/index.mdx +++ b/docs/platforms/android/manual-setup/index.mdx @@ -83,8 +83,11 @@ Configuration is done via the application `AndroidManifest.xml`. Here's an examp + See the Android Session Replay documentation for details: https://docs.sentry.io/platforms/android/session-replay/#screenshot-strategy --> + + + ``` @@ -160,9 +163,11 @@ public class MyApplication extends Application { options.getSessionReplay().setOnErrorSampleRate(1.0); // If your application has strict PII requirements we recommend using the Canvas screenshot strategy. - // See the Android Session Replay documentation for details: https://docs.sentry.io/platforms/android/session-replay/#screenshot-strategy. + // See the Android Session Replay documentation for details: https://docs.sentry.io/platforms/android/session-replay/#screenshot-strategy // options.getSessionReplay().setScreenshotStrategy(ScreenshotStrategyType.CANVAS); + // enable logs to be sent to Sentry. Use Sentry.logger() to capture logs or check the available integrations that capture logs automatically: https://docs.sentry.io/platforms/android/logs/#integrations + options.getLogs().setEnabled(true); // Add a callback that will be used before the event is sent to Sentry. // With this callback, you can modify the event or, when returning null, also discard the event. @@ -214,9 +219,12 @@ class MyApplication : Application() { options.sessionReplay.onErrorSampleRate = 1.0 // If your application has strict PII requirements we recommend using the Canvas screenshot strategy. - // See the Android Session Replay documentation for details: https://docs.sentry.io/platforms/android/session-replay/#screenshot-strategy. + // See the Android Session Replay documentation for details: https://docs.sentry.io/platforms/android/session-replay/#screenshot-strategy // options.sessionReplay.screenshotStrategy = ScreenshotStrategyType.CANVAS + // enable logs to be sent to Sentry. Use Sentry.logger() to capture logs or check the available integrations that capture logs automatically: https://docs.sentry.io/platforms/android/logs/#integrations + options.logs.isEnabled = true; + // Add a callback that will be used before the event is sent to Sentry. // With this callback, you can modify the event or, when returning null, also discard the event. options.beforeSend = From 04cdc16d91d99f8ce95336cd25f52af5f2aed7fe Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Wed, 11 Feb 2026 10:27:31 +0100 Subject: [PATCH 7/9] Add tombstone flag to the init config --- docs/platforms/android/manual-setup/index.mdx | 114 +++++++++--------- 1 file changed, 60 insertions(+), 54 deletions(-) diff --git a/docs/platforms/android/manual-setup/index.mdx b/docs/platforms/android/manual-setup/index.mdx index 3ecfdabdb4075e..31a9d5e33e4d57 100644 --- a/docs/platforms/android/manual-setup/index.mdx +++ b/docs/platforms/android/manual-setup/index.mdx @@ -88,6 +88,8 @@ Configuration is done via the application `AndroidManifest.xml`. Here's an examp + + ``` @@ -127,119 +129,123 @@ The SDK can catch errors and crashes only after you've initialized it. So, we re Configuration options will be loaded from the manifest so that you don't need to have the static properties in your code. In the `init` method, you can provide a callback that will modify the configuration and also register new options. - -```java +```kotlin import io.sentry.ScreenshotStrategyType; import io.sentry.SentryLevel; import io.sentry.ProfileLifecycle; import io.sentry.android.core.SentryAndroid; import android.app.Application; +import io.sentry.SentryOptions -public class MyApplication extends Application { - public void onCreate() { - super.onCreate(); +class MyApplication : Application() { + override fun onCreate() { + super.onCreate() - SentryAndroid.init(this, options -> { + SentryAndroid.init(this) { options -> // Required: set your sentry.io project identifier (DSN) - options.setDsn("___PUBLIC_DSN___"); + options.dsn = "___PUBLIC_DSN___" // Add data like request headers, user ip address and device name, see https://docs.sentry.io/platforms/android/data-management/data-collected/ for more info - options.setSendDefaultPii(true); + options.isSendDefaultPii = true // enable automatic traces for user interactions (clicks, swipes, scrolls) - options.setEnableUserInteractionTracing(true); + options.isEnableUserInteractionTracing = true // enable screenshot for crashes - options.setAttachScreenshot(true); + options.isAttachScreenshot = true // enable view hierarchy for crashes - options.setAttachViewHierarchy(true); + options.isAttachViewHierarchy = true // enable the performance API by setting a sample-rate, adjust in production env - options.setTracesSampleRate(1.0); + options.tracesSampleRate = 1.0 // enable UI profiling, adjust in production env. This is evaluated only once per session - options.setProfileSessionSampleRate(1.0); + options.profileSessionSampleRate = 1.0 // set profiling mode. For more info see https://docs.sentry.io/platforms/android/profiling/#enabling-ui-profiling - options.setProfileLifecycle(ProfileLifecycle.TRACE); + options.profileLifecycle = ProfileLifecycle.TRACE // enable profiling on app start. The app start profile will be stopped automatically when the app start root span finishes - options.setStartProfilerOnAppStart(true); + options.isStartProfilerOnAppStart = true // record session replays for 100% of errors and 10% of sessions - options.getSessionReplay().setSessionSampleRate(0.1); - options.getSessionReplay().setOnErrorSampleRate(1.0); + options.sessionReplay.sessionSampleRate = 0.1 + options.sessionReplay.onErrorSampleRate = 1.0 // If your application has strict PII requirements we recommend using the Canvas screenshot strategy. // See the Android Session Replay documentation for details: https://docs.sentry.io/platforms/android/session-replay/#screenshot-strategy - // options.getSessionReplay().setScreenshotStrategy(ScreenshotStrategyType.CANVAS); + // options.sessionReplay.screenshotStrategy = ScreenshotStrategyType.CANVAS // enable logs to be sent to Sentry. Use Sentry.logger() to capture logs or check the available integrations that capture logs automatically: https://docs.sentry.io/platforms/android/logs/#integrations - options.getLogs().setEnabled(true); + options.logs.isEnabled = true; + + // enable tombstone support for richer Native crashes context. See more at https://docs.sentry.io/platforms/android/configuration/tombstones/ + options.isTombstoneEnabled = true; // Add a callback that will be used before the event is sent to Sentry. // With this callback, you can modify the event or, when returning null, also discard the event. - options.setBeforeSend((event, hint) -> { - if (SentryLevel.DEBUG.equals(event.getLevel())) { - return null; - } else { - return event; + options.beforeSend = + SentryOptions.BeforeSendCallback { event, hint -> + if (SentryLevel.DEBUG == event.level) { + null + } else { + event + } } - }); - }); + } } } ``` -```kotlin +```java import io.sentry.ScreenshotStrategyType; import io.sentry.SentryLevel; import io.sentry.ProfileLifecycle; import io.sentry.android.core.SentryAndroid; import android.app.Application; -import io.sentry.SentryOptions -class MyApplication : Application() { - override fun onCreate() { - super.onCreate() +public class MyApplication extends Application { + public void onCreate() { + super.onCreate(); - SentryAndroid.init(this) { options -> + SentryAndroid.init(this, options -> { // Required: set your sentry.io project identifier (DSN) - options.dsn = "___PUBLIC_DSN___" + options.setDsn("___PUBLIC_DSN___"); // Add data like request headers, user ip address and device name, see https://docs.sentry.io/platforms/android/data-management/data-collected/ for more info - options.isSendDefaultPii = true + options.setSendDefaultPii(true); // enable automatic traces for user interactions (clicks, swipes, scrolls) - options.isEnableUserInteractionTracing = true + options.setEnableUserInteractionTracing(true); // enable screenshot for crashes - options.isAttachScreenshot = true + options.setAttachScreenshot(true); // enable view hierarchy for crashes - options.isAttachViewHierarchy = true + options.setAttachViewHierarchy(true); // enable the performance API by setting a sample-rate, adjust in production env - options.tracesSampleRate = 1.0 + options.setTracesSampleRate(1.0); // enable UI profiling, adjust in production env. This is evaluated only once per session - options.profileSessionSampleRate = 1.0 + options.setProfileSessionSampleRate(1.0); // set profiling mode. For more info see https://docs.sentry.io/platforms/android/profiling/#enabling-ui-profiling - options.profileLifecycle = ProfileLifecycle.TRACE + options.setProfileLifecycle(ProfileLifecycle.TRACE); // enable profiling on app start. The app start profile will be stopped automatically when the app start root span finishes - options.isStartProfilerOnAppStart = true + options.setStartProfilerOnAppStart(true); // record session replays for 100% of errors and 10% of sessions - options.sessionReplay.sessionSampleRate = 0.1 - options.sessionReplay.onErrorSampleRate = 1.0 + options.getSessionReplay().setSessionSampleRate(0.1); + options.getSessionReplay().setOnErrorSampleRate(1.0); // If your application has strict PII requirements we recommend using the Canvas screenshot strategy. // See the Android Session Replay documentation for details: https://docs.sentry.io/platforms/android/session-replay/#screenshot-strategy - // options.sessionReplay.screenshotStrategy = ScreenshotStrategyType.CANVAS + // options.getSessionReplay().setScreenshotStrategy(ScreenshotStrategyType.CANVAS); // enable logs to be sent to Sentry. Use Sentry.logger() to capture logs or check the available integrations that capture logs automatically: https://docs.sentry.io/platforms/android/logs/#integrations - options.logs.isEnabled = true; + options.getLogs().setEnabled(true); + + // enable tombstone support for richer Native crashes context. See more at https://docs.sentry.io/platforms/android/configuration/tombstones/ + options.setTombstoneEnabled(true); // Add a callback that will be used before the event is sent to Sentry. // With this callback, you can modify the event or, when returning null, also discard the event. - options.beforeSend = - SentryOptions.BeforeSendCallback { event, hint -> - if (SentryLevel.DEBUG == event.level) { - null - } else { - event - } + options.setBeforeSend((event, hint) -> { + if (SentryLevel.DEBUG.equals(event.getLevel())) { + return null; + } else { + return event; } - } + }); + }); } } ``` - Additional options can be found on our dedicated options page. From 0cff43268f00e9b8b2315147607ce67691fad43e Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Wed, 11 Feb 2026 10:39:26 +0100 Subject: [PATCH 8/9] add space --- docs/platforms/android/manual-setup/index.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/platforms/android/manual-setup/index.mdx b/docs/platforms/android/manual-setup/index.mdx index 31a9d5e33e4d57..5c4ddc2ccd3c8c 100644 --- a/docs/platforms/android/manual-setup/index.mdx +++ b/docs/platforms/android/manual-setup/index.mdx @@ -88,6 +88,7 @@ Configuration is done via the application `AndroidManifest.xml`. Here's an examp + From 06ba4c4fc6276c500d42072abac3bc6315bf5c41 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Thu, 26 Feb 2026 14:39:27 +0100 Subject: [PATCH 9/9] Add screenshot masking documentation for Android Co-Authored-By: Claude Opus 4.6 --- .../enriching-events/screenshots/index.mdx | 159 ++++++++++++++++++ .../attach-screenshots/android.mdx | 6 + 2 files changed, 165 insertions(+) diff --git a/docs/platforms/android/enriching-events/screenshots/index.mdx b/docs/platforms/android/enriching-events/screenshots/index.mdx index 3b81a053e0de61..ea669f070f72bc 100644 --- a/docs/platforms/android/enriching-events/screenshots/index.mdx +++ b/docs/platforms/android/enriching-events/screenshots/index.mdx @@ -16,6 +16,165 @@ Because screenshots may contain +## Screenshot Masking + +Screenshot masking allows you to mask sensitive data in screenshots before they are captured. You can customize this behavior to fit your application's needs. + + + +Screenshot masking requires the `sentry-android-replay` module at runtime. This module is included by default if you use the `sentry-android` dependency. If you only depend on `sentry-android-core`, add the replay module explicitly: + +```groovy {filename:app/build.gradle} +dependencies { + implementation 'io.sentry:sentry-android-replay:{{@inject packages.version('sentry.java.android', '8.34.0') }}' +} +``` + +```kotlin {filename:app/build.gradle.kts} +dependencies { + implementation("io.sentry:sentry-android-replay:{{@inject packages.version('sentry.java.android', '8.34.0') }}") +} +``` + +If masking options are configured but the module is not available at runtime, the SDK will skip capturing screenshots entirely to avoid leaking sensitive data. + + + +### Default Masking Behavior + +Unlike Session Replay, screenshot masking is **disabled by default**. You can enable masking for all text and image content: + +```java +import io.sentry.android.core.SentryAndroid; + +SentryAndroid.init(this, options -> { + options.getScreenshot().setMaskAllText(true); + options.getScreenshot().setMaskAllImages(true); +}); +``` + +```kotlin +import io.sentry.android.core.SentryAndroid + +SentryAndroid.init(this) { options -> + options.screenshot.setMaskAllText(true) + options.screenshot.setMaskAllImages(true) +} +``` + +```xml {filename:AndroidManifest.xml} + + + + +``` + + + +When `setMaskAllImages(true)` is set, the SDK will also mask `WebView`, `VideoView`, CameraX `PreviewView`, ExoPlayer, and Media3 player views in addition to `ImageView`. + + + +### Mask by View Class + +You can choose which type of view to mask or unmask by using `addMaskViewClass` or `addUnmaskViewClass`. These accept fully-qualified class names and apply to all subclasses of the specified class as well. + +```java +import io.sentry.android.core.SentryAndroid; + +SentryAndroid.init(this, options -> { + options.getScreenshot().addMaskViewClass("com.example.MyCustomView"); + options.getScreenshot().addUnmaskViewClass("com.example.PublicLabel"); +}); +``` + +```kotlin +import io.sentry.android.core.SentryAndroid + +SentryAndroid.init(this) { options -> + options.screenshot.addMaskViewClass("com.example.MyCustomView") + options.screenshot.addUnmaskViewClass("com.example.PublicLabel") +} +``` + + + +If you use R8/ProGuard, make sure to keep the class names you reference in masking rules. Obfuscated class names will not match at runtime. + + + +### Mask by View Instance + +You can mask or unmask specific view instances using extension functions from the `sentry-android-replay` module: + +```kotlin +import io.sentry.android.replay.sentryReplayMask +import io.sentry.android.replay.sentryReplayUnmask + +myTextView.sentryReplayMask() +myImageView.sentryReplayUnmask() +``` + +In Kotlin and Java, you can also use view tags with the `sentry_privacy` resource ID: + +```kotlin +import io.sentry.android.replay.R + +view.setTag(R.id.sentry_privacy, "mask") +view.setTag(R.id.sentry_privacy, "unmask") +``` + +```java +import io.sentry.android.replay.R; + +view.setTag(R.id.sentry_privacy, "mask"); +view.setTag(R.id.sentry_privacy, "unmask"); +``` + +You can also set masking via XML layout tags: + +```xml + + + +``` + +Alternatively, you can use the `android:tag` attribute with the `sentry-mask` or `sentry-unmask` string values: + +```xml + +``` + +### Jetpack Compose + +For Jetpack Compose, use the `sentryReplayMask()` and `sentryReplayUnmask()` modifiers: + +```kotlin +import io.sentry.android.replay.sentryReplayMask +import io.sentry.android.replay.sentryReplayUnmask + +@Composable +fun MyScreen() { + Column { + Text( + text = "Sensitive info", + modifier = Modifier.sentryReplayMask() + ) + Text( + text = "Public info", + modifier = Modifier.sentryReplayUnmask() + ) + } +} +``` + ## Viewing Screenshots If one is available, you'll see a thumbnail of the screenshot when you click on a specific issue from the [**Issues**](https://demo.sentry.io/issues/) page. diff --git a/platform-includes/enriching-events/attach-screenshots/android.mdx b/platform-includes/enriching-events/attach-screenshots/android.mdx index 93a5272c8601d7..712fedc6b50bd7 100644 --- a/platform-includes/enriching-events/attach-screenshots/android.mdx +++ b/platform-includes/enriching-events/attach-screenshots/android.mdx @@ -4,6 +4,12 @@ ``` + + +Before enabling screenshots in production, verify your masking configuration to ensure no sensitive data is captured. If you find any masking issues or sensitive data that should be masked but isn't, please [create a GitHub issue](https://github.com/getsentry/sentry-java/issues/new/choose) and avoid deploying to production with screenshots enabled until the issue is resolved. + + + ### Customize Screenshot Capturing