build: Bump AGP to 9.2.1 and migrate Android modules#5779
Conversation
📲 Install BuildsAndroid
|
eaea270 to
aed7d88
Compare
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| b193867 | 331.08 ms | 397.06 ms | 65.98 ms |
| 3d205d0 | 352.15 ms | 432.53 ms | 80.38 ms |
| 22ff2c7 | 306.60 ms | 336.65 ms | 30.05 ms |
| a5ab36f | 320.47 ms | 389.77 ms | 69.30 ms |
| 539ca63 | 313.51 ms | 355.43 ms | 41.92 ms |
| dba088c | 365.46 ms | 366.31 ms | 0.85 ms |
| 4e3e79d | 312.02 ms | 376.24 ms | 64.22 ms |
| 7314dbe | 437.83 ms | 505.64 ms | 67.81 ms |
| ad8da22 | 314.38 ms | 352.29 ms | 37.91 ms |
| bb0ff41 | 344.70 ms | 413.82 ms | 69.12 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| b193867 | 1.58 MiB | 2.19 MiB | 620.00 KiB |
| 3d205d0 | 1.58 MiB | 2.10 MiB | 532.97 KiB |
| 22ff2c7 | 0 B | 0 B | 0 B |
| a5ab36f | 1.58 MiB | 2.12 MiB | 555.26 KiB |
| 539ca63 | 1.58 MiB | 2.12 MiB | 551.41 KiB |
| dba088c | 1.58 MiB | 2.13 MiB | 558.99 KiB |
| 4e3e79d | 0 B | 0 B | 0 B |
| 7314dbe | 1.58 MiB | 2.10 MiB | 533.45 KiB |
| ad8da22 | 1.58 MiB | 2.29 MiB | 719.83 KiB |
| bb0ff41 | 0 B | 0 B | 0 B |
7a60384 to
7d0c248
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7d0c248. Configure here.
| kotlin { compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8 } | ||
| // AGP 9 only generates unit tests for the testBuildType. CI disables the debug | ||
| // variant, so unit tests must target release to run at all. | ||
| testBuildType = "release" |
There was a problem hiding this comment.
Release tests forced outside CI
Medium Severity
testBuildType = "release" is applied unconditionally, but debug variants are only disabled in CI via shouldSkipDebugVariant. Locally, that removes testDebugUnitTest even though debug is still enabled, so the documented testDebugUnitTest workflow no longer works.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 7d0c248. Configure here.
Raise the minimum AGP to 9.0.0 (default fallback 9.2.1) and perform the AGP 9 migration: refresh the AGP-compat matrix (9.0.0/9.1.1/9.2.1), add the AGP 9 opt-outs (android.builtInKotlin/newDsl, lint 9.2.1), pin Java and Kotlin targets to 8 across the Android library modules, set testBuildType to release for unit tests (including sentry-compose), bump the uitest modules to JVM 11, and resolve the AGP 9.2 lint findings. Robolectric 4.15 caps at API 35, so pin the affected tests with @config(sdk = [35]) to keep them green against targetSdk 36. lint 9.2.1 flags compileSdk 36 as outdated (37 is available); disable GradleDependency for the Android modules since the SDK bump lives in the API 37 PR. Split out from the API 37 bump (#5768) so the toolchain upgrade lands on its own. compileSdk/targetSdk stay at 36 here. Co-authored-by: Adam Brown <adam.brown@sentry.io> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EmE8hdaj9H9K61opK2PZ6U
7d0c248 to
fb2e3e2
Compare
| fail-fast: false | ||
| matrix: | ||
| agp: [ '8.7.0','8.8.0','8.9.0' ] | ||
| agp: [ '9.0.0', '9.1.1', '9.2.1' ] |
There was a problem hiding this comment.
reminder: we publish the entry-android artifact compiled against 9.2.1 as set in Config.kt below. this test compiles the sentry-android artifact against different versions of AGP meaning the tests do not represent our published artifact
|
|
||
| @SuppressWarnings("deprecation") | ||
| @SuppressLint({"NewApi", "PrivateApi"}) | ||
| @SuppressLint({"NewApi", "PrivateApi", "DiscouragedPrivateApi"}) |
There was a problem hiding this comment.
this is the Choreographer.class.getDeclaredField("mLastFrameTimeNanos"); on line 144
| import org.robolectric.annotation.Config | ||
|
|
||
| @RunWith(AndroidJUnit4::class) | ||
| @Config(sdk = [35]) |
There was a problem hiding this comment.
we should investigate and/or update robolectric to fix the failure this was causing in a separate PR
| warningsAsErrors = true | ||
| checkDependencies = true | ||
| // Suppress OldTargetApi: lint 8.13.1 expects API 37 but we target 36 | ||
| // Suppress OldTargetApi: lint 9.2.1 expects API 37 but we target 36 |
There was a problem hiding this comment.
we should remove this once we bump the SDK
| } | ||
| } | ||
| kotlin { compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8 } | ||
| kotlin { compilerOptions.jvmTarget = JvmTarget.JVM_11 } |
There was a problem hiding this comment.
AGP defaults to 11 now. Since these are our UI tests, it doesn't affect the compiled artifact.
| // AGP 9.2 bundles lint 9.2.1, which flags compileSdk 36 as outdated because 37 is available. | ||
| // We intentionally stay on compileSdk 36 until the API 37 bump (#5768), so silence that check | ||
| // for every Android module (library and application). | ||
| pluginManager.withPlugin("com.android.library") { |
There was a problem hiding this comment.
we should remove this once we bump to compile/target sdk 37
| compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8 | ||
| compilerOptions.languageVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9 | ||
| compilerOptions.apiVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9 | ||
| kotlin { |
There was a problem hiding this comment.
just a random fix here, this should be declared on the kotlin extension not the task like all the other modules
|
I'm guessing the failing snapshot test diff is due to a bump in layoutlib which mustve changed the default theme from dark to light: https://github.com/getsentry/sentry-java/pull/5779/checks?check_run_id=87875970201 I went ahead and approved it. I don't think it is worth investigating |


We need to bump AGP to 9.2 because compile SDK introduced a breaking change (
37.0vs37) which makes it very difficult to compile using AGP 8.X.AGP 9.X introduced several breaking changes that we try to mitigate in this PR.
android.builtInKotlin=falseandroid.builtInKotlin=falseFixes #5777
Linear: JAVA-649 (https://linear.app/getsentry/issue/JAVA-649)
#skip-changelog
🤖 Generated with Claude Code
https://claude.ai/code/session_01EmE8hdaj9H9K61opK2PZ6U