diff --git a/docs/product/snapshots/android/index.mdx b/docs/product/snapshots/android/index.mdx new file mode 100644 index 0000000000000..affa3e9ca819b --- /dev/null +++ b/docs/product/snapshots/android/index.mdx @@ -0,0 +1,104 @@ +--- +title: Android +sidebar_order: 30 +description: Set up snapshot testing for Android apps with the Sentry Android Gradle Plugin. +--- + + + +Set up snapshot testing for your Android app with the Sentry Android Gradle Plugin. Run snapshot tests locally or in your own CI using your preferred snapshot library, then upload the generated images to Sentry for image diffing, visual review, and GitHub check status updates. + +## Step 1: Enable Snapshots + +Ensure the [Sentry Android Gradle Plugin](/platforms/android/configuration/gradle/) version 6.4.0 or higher is applied and configured. + +Then enable snapshots in your `build.gradle`: + +```kotlin +sentry { + snapshots { + enabled = true + } +} +``` + +## Step 2: Connect Your Snapshot Tool + +### Paparazzi (Recommended) + +If you already have [Paparazzi](https://github.com/cashapp/paparazzi) configured, add `generateSnapshotTests = false` to your snapshot config: + +```kotlin +sentry { + snapshots { + enabled = true + generateSnapshotTests = false + } +} +``` + +Then continue to [Step 3](#step-3-test-locally). + +--- + +If you don't have Paparazzi yet, first choose a version compatible with your project: + +| Version | Gradle | compileSdk | JDK | compose-bom | +| --------------- | -------------- | ---------- | --- | ------------ | +| `2.0.0-alpha04` | 9.1.x or 9.2.x | 36 | 21+ | > 2025.05.00 | +| `1.3.5` | 8.x or 9.x | ≤ 35 | 17+ | ≤ 2025.04.00 | + +Then apply the plugin: + +```kotlin +plugins { + // existing plugins + id("app.cash.paparazzi") version "" +} +``` + +Paparazzi integrates with ComposePreviewScanner to automatically generate snapshots for all Compose Previews in your project — no test-writing required. + +Then continue to [Step 3](#step-3-test-locally). + +### Roborazzi + +If you already have [Roborazzi](https://github.com/takahirom/roborazzi) configured, wire the Sentry upload task to the output of your Roborazzi record task: + +```kotlin +afterEvaluate { + tasks.named("sentryUploadSnapshotsDebug") { + dependsOn(tasks.named("recordRoborazziDebug")) + snapshotsPath.set( + project.extensions.getByType().outputDir + ) + } +} +``` + +Then continue to [Step 3](#step-3-test-locally). + +### Other Tools + +The same pattern works with any snapshot tool. Set `snapshotsPath` to the directory your tool writes images to, and add a `dependsOn` for the task that generates them: + +```kotlin +afterEvaluate { + tasks.named("sentryUploadSnapshotsDebug") { + dependsOn(tasks.named("yourSnapshotTask")) + snapshotsPath.set(layout.projectDirectory.dir("path/to/snapshots")) + } +} +``` + +Alternatively, you can use `sentry-cli` directly to upload images. See [Uploading Snapshots](/product/snapshots/uploading-snapshots/) for the general upload structure. + +## Step 3: Test Locally + +Verify your setup by running: + +```bash +./gradlew sentryUploadSnapshotsDebug +``` + +If that succeeds, you can proceed with integrating into CI. See [Uploading Snapshots](/product/snapshots/uploading-snapshots/#upload-with-ci) for an example CI workflow.