From f5fb15922e491395cfb92fd7354034782729963e Mon Sep 17 00:00:00 2001 From: Nelson Osacky Date: Tue, 10 Nov 2026 15:20:56 +0100 Subject: [PATCH] build(android): Bump AGP to 9.5.1 Raise the default Android Gradle Plugin from 9.4.0 to 9.5.1, the latest stable release. The AGP matrix moves to 9.0.0/9.4.0/9.5.1, keeping the minimum supported version and the previous default, and the replay snapshot upload follows the new default. Lint 9.5 can't load the custom checks bundled with older androidx.lifecycle releases and reports ObsoleteLintCustomCheck, which warningsAsErrors fails on. Disable it in the affected modules; the skipped checks cover lifecycle APIs those modules don't call. Lint 9.5's new ThreadConstraint check flags ScreenshotUtils.takeScreenshot, which is safe to call from any thread because captureScreenshot posts the view draw to the UI thread. Suppress it there. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/agp-matrix.yml | 4 ++-- gradle/libs.versions.toml | 2 +- .../sentry/android/core/internal/util/ScreenshotUtils.java | 5 ++++- sentry-android-fragment/build.gradle.kts | 4 ++++ .../sentry-uitest-android/build.gradle.kts | 4 ++++ sentry-android-navigation/build.gradle.kts | 4 ++++ sentry-android-replay/build.gradle.kts | 4 ++++ sentry-compose/build.gradle.kts | 4 ++++ 8 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.github/workflows/agp-matrix.yml b/.github/workflows/agp-matrix.yml index 7b1980b114..26463fbcf3 100644 --- a/.github/workflows/agp-matrix.yml +++ b/.github/workflows/agp-matrix.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - agp: [ '9.0.0', '9.2.1', '9.4.0' ] + agp: [ '9.0.0', '9.4.0', '9.5.1' ] integrations: [ true, false ] name: AGP Matrix Release - AGP ${{ matrix.agp }} - Integrations ${{ matrix.integrations }} @@ -25,7 +25,7 @@ jobs: VERSION_AGP: ${{ matrix.agp }} APPLY_SENTRY_INTEGRATIONS: ${{ matrix.integrations }} # Upload replay snapshots from one cell only. Forks don't have access to the upload secret. - UPLOAD_REPLAY_SNAPSHOTS: ${{ matrix.agp == '9.4.0' && matrix.integrations && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }} + UPLOAD_REPLAY_SNAPSHOTS: ${{ matrix.agp == '9.5.1' && matrix.integrations && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }} steps: - name: Checkout Repo diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3717d77fcd..ad88e6c03f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -41,7 +41,7 @@ room2 = "2.8.4" room3 = "3.0.0-rc01" sagp = "6.13.0" # The AGP matrix job overrides this with the VERSION_AGP env var, through each build's settings. -agp = "9.4.0" +agp = "9.5.1" sqlite = "2.6.2" sqliteRc = "2.8.0-alpha03" # Required by Room3 3.0.0-rc* slf4j = "1.7.30" diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/internal/util/ScreenshotUtils.java b/sentry-android-core/src/main/java/io/sentry/android/core/internal/util/ScreenshotUtils.java index a91a881848..776d0103d2 100644 --- a/sentry-android-core/src/main/java/io/sentry/android/core/internal/util/ScreenshotUtils.java +++ b/sentry-android-core/src/main/java/io/sentry/android/core/internal/util/ScreenshotUtils.java @@ -38,7 +38,10 @@ public final class ScreenshotUtils { } // Used by Hybrid SDKs - @SuppressLint("NewApi") + // Lint infers a UI-thread constraint from the View calls in captureScreenshot, which clashes with + // Bitmap.compress's @WorkerThread. captureScreenshot is safe from any thread, as it posts the + // view draw to the UI thread when it isn't already on it. + @SuppressLint({"NewApi", "ThreadConstraint"}) public static @Nullable byte[] takeScreenshot( final @NotNull Activity activity, final @NotNull IThreadChecker threadChecker, diff --git a/sentry-android-fragment/build.gradle.kts b/sentry-android-fragment/build.gradle.kts index 462003eb06..80e04a4b78 100644 --- a/sentry-android-fragment/build.gradle.kts +++ b/sentry-android-fragment/build.gradle.kts @@ -54,6 +54,10 @@ android { // We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks. checkReleaseBuilds = false + + // Lint 9.5 can't load the custom checks bundled with older androidx.lifecycle releases and + // reports that it skips them. They only cover lifecycle APIs this module doesn't call. + disable += "ObsoleteLintCustomCheck" } buildFeatures { buildConfig = true } diff --git a/sentry-android-integration-tests/sentry-uitest-android/build.gradle.kts b/sentry-android-integration-tests/sentry-uitest-android/build.gradle.kts index d5f90f7600..784bd463c5 100644 --- a/sentry-android-integration-tests/sentry-uitest-android/build.gradle.kts +++ b/sentry-android-integration-tests/sentry-uitest-android/build.gradle.kts @@ -77,6 +77,10 @@ android { // This module is the one lint picks to check the build root's Gradle wrapper, and this check // compares it with the latest Gradle release online, so every new release would fail the build. disable += "AndroidGradlePluginVersion" + + // Lint 9.5 can't load the custom checks bundled with older androidx.lifecycle releases and + // reports that it skips them. They only cover lifecycle APIs this module doesn't call. + disable += "ObsoleteLintCustomCheck" } androidComponents.beforeVariants { diff --git a/sentry-android-navigation/build.gradle.kts b/sentry-android-navigation/build.gradle.kts index 2b8d322470..af9aef5166 100644 --- a/sentry-android-navigation/build.gradle.kts +++ b/sentry-android-navigation/build.gradle.kts @@ -54,6 +54,10 @@ android { // We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks. checkReleaseBuilds = false + + // Lint 9.5 can't load the custom checks bundled with older androidx.lifecycle releases and + // reports that it skips them. They only cover lifecycle APIs this module doesn't call. + disable += "ObsoleteLintCustomCheck" } buildFeatures { buildConfig = true } diff --git a/sentry-android-replay/build.gradle.kts b/sentry-android-replay/build.gradle.kts index 31c3c2c17c..8d17ff27f1 100644 --- a/sentry-android-replay/build.gradle.kts +++ b/sentry-android-replay/build.gradle.kts @@ -62,6 +62,10 @@ android { // We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks. checkReleaseBuilds = false + + // Lint 9.5 can't load the custom checks bundled with older androidx.lifecycle releases and + // reports that it skips them. They only cover lifecycle APIs this module doesn't call. + disable += "ObsoleteLintCustomCheck" } buildFeatures { buildConfig = true } diff --git a/sentry-compose/build.gradle.kts b/sentry-compose/build.gradle.kts index cf0dfb7d50..6bcd20e2a3 100644 --- a/sentry-compose/build.gradle.kts +++ b/sentry-compose/build.gradle.kts @@ -116,6 +116,10 @@ android { // We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks. checkReleaseBuilds = false + + // Lint 9.5 can't load the custom checks bundled with older androidx.lifecycle releases and + // reports that it skips them. They only cover lifecycle APIs this module doesn't call. + disable += "ObsoleteLintCustomCheck" } buildFeatures { buildConfig = true }