Skip to content

Commit fb2e3e2

Browse files
runningcodeclaude
andcommitted
build: Bump AGP to 9.2.1 and migrate Android modules (JAVA-649)
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
1 parent 031ec33 commit fb2e3e2

26 files changed

Lines changed: 135 additions & 38 deletions

File tree

.github/workflows/agp-matrix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
agp: [ '8.7.0','8.8.0','8.9.0' ]
20+
agp: [ '9.0.0', '9.1.1', '9.2.1' ]
2121
integrations: [ true, false ]
2222

2323
name: AGP Matrix Release - AGP ${{ matrix.agp }} - Integrations ${{ matrix.integrations }}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- Backfill release, environment, distribution, tags, and app version/build—and use the matching replay-on-error sample rate—for `ApplicationExitInfo` ANR and native crash events captured before SDK initialization, without reusing options cached by a later app update ([#5762](https://github.com/getsentry/sentry-java/pull/5762))
88

9+
### Dependencies
10+
11+
- The SDK is now compiled with Android Gradle Plugin 9.2.1 ([#5779](https://github.com/getsentry/sentry-java/pull/5779))
12+
913
## 8.49.0
1014

1115
### Features

build.gradle.kts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@ allprojects {
113113
subprojects {
114114
apply { plugin("io.sentry.spotless") }
115115

116+
// AGP 9.2 bundles lint 9.2.1, which flags compileSdk 36 as outdated because 37 is available.
117+
// We intentionally stay on compileSdk 36 until the API 37 bump (#5768), so silence that check
118+
// for every Android module (library and application).
119+
pluginManager.withPlugin("com.android.library") {
120+
extensions.configure<com.android.build.gradle.BaseExtension> {
121+
lintOptions { disable("GradleDependency") }
122+
}
123+
}
124+
pluginManager.withPlugin("com.android.application") {
125+
extensions.configure<com.android.build.gradle.BaseExtension> {
126+
lintOptions { disable("GradleDependency") }
127+
}
128+
}
129+
116130
plugins.withId(Config.QualityPlugins.detektPlugin) {
117131
configure<DetektExtension> {
118132
buildUponDefaultConfig = true
@@ -168,6 +182,18 @@ subprojects {
168182
}
169183
}
170184

185+
// AGP 9 defaults Android modules to Java 11. Pin the published library modules back
186+
// to Java 8 so their bytecode stays consumable by Java 8 projects, mirroring the
187+
// java-library pin above.
188+
plugins.withId("com.android.library") {
189+
configure<com.android.build.gradle.BaseExtension> {
190+
compileOptions {
191+
sourceCompatibility = JavaVersion.VERSION_1_8
192+
targetCompatibility = JavaVersion.VERSION_1_8
193+
}
194+
}
195+
}
196+
171197
apply<MavenPublishPlugin>()
172198

173199
afterEvaluate {

buildSrc/src/main/java/Config.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
object Config {
3-
val AGP = System.getenv("VERSION_AGP") ?: "8.13.1"
3+
val AGP = System.getenv("VERSION_AGP") ?: "9.2.1"
44
val kotlinStdLib = "stdlib-jdk8"
55
val kotlinStdLibVersionAndroid = "1.9.24"
66
val kotlinTestJunit = "test-junit"

gradle.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
1010

1111
# AndroidX required by AGP >= 3.6.x
1212
android.useAndroidX=true
13-
android.experimental.lint.version=8.13.1
13+
# AGP 9+ migration opt-outs until we remove kotlin-android plugin and adopt built-in Kotlin.
14+
android.builtInKotlin=false
15+
android.newDsl=false
16+
android.experimental.lint.version=9.2.1
1417

1518
# Release information
1619
versionName=8.49.0

sentry-android-core/build.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import net.ltgt.gradle.errorprone.errorprone
22
import org.jetbrains.kotlin.config.KotlinCompilerVersion
3+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
34

45
plugins {
56
id("com.android.library")
@@ -33,7 +34,11 @@ android {
3334
getByName("release") { consumerProguardFiles("proguard-rules.pro") }
3435
}
3536

36-
kotlin { compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8 }
37+
// AGP 9 only generates unit tests for the testBuildType. CI disables the debug
38+
// variant, so unit tests must target release to run at all.
39+
testBuildType = "release"
40+
41+
kotlin { compilerOptions.jvmTarget = JVM_1_8 }
3742

3843
testOptions {
3944
animationsDisabled = true

sentry-android-core/src/main/java/io/sentry/android/core/internal/util/SentryFrameMetricsCollector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public SentryFrameMetricsCollector(
9191
}
9292

9393
@SuppressWarnings("deprecation")
94-
@SuppressLint({"NewApi", "PrivateApi"})
94+
@SuppressLint({"NewApi", "PrivateApi", "DiscouragedPrivateApi"})
9595
public SentryFrameMetricsCollector(
9696
final @NotNull Context context,
9797
final @NotNull ILogger logger,

sentry-android-core/src/main/res/layout/sentry_dialog_user_feedback.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
android:layout_height="wrap_content"
4848
android:hint="Your Name"
4949
android:inputType="textPersonName"
50+
android:autofillHints="name"
5051
android:background="@drawable/sentry_edit_text_border"
5152
android:paddingHorizontal="8dp"
5253
android:layout_below="@id/sentry_dialog_user_feedback_txt_name" />
@@ -66,6 +67,7 @@
6667
android:layout_height="wrap_content"
6768
android:hint="your.email@example.org"
6869
android:inputType="textEmailAddress"
70+
android:autofillHints="emailAddress"
6971
android:background="@drawable/sentry_edit_text_border"
7072
android:paddingHorizontal="8dp"
7173
android:layout_below="@id/sentry_dialog_user_feedback_txt_email" />
@@ -85,6 +87,7 @@
8587
android:layout_height="wrap_content"
8688
android:lines="6"
8789
android:inputType="textMultiLine"
90+
android:importantForAutofill="no"
8891
android:gravity="top|left"
8992
android:hint="What's the bug? What did you expect?"
9093
android:background="@drawable/sentry_edit_text_border"

sentry-android-distribution/build.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
12
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
23

34
plugins {
@@ -12,6 +13,10 @@ android {
1213
defaultConfig { minSdk = libs.versions.minSdk.get().toInt() }
1314
buildFeatures { buildConfig = false }
1415

16+
// AGP 9 only generates unit tests for the testBuildType. CI disables the debug
17+
// variant, so unit tests must target release to run at all.
18+
testBuildType = "release"
19+
1520
testOptions {
1621
unitTests.apply {
1722
isReturnDefaultValues = true
@@ -21,7 +26,7 @@ android {
2126
}
2227

2328
kotlin {
24-
jvmToolchain(17)
29+
compilerOptions.jvmTarget = JVM_1_8
2530
compilerOptions.languageVersion = KotlinVersion.KOTLIN_1_9
2631
explicitApi()
2732
}

sentry-android-distribution/src/test/java/io/sentry/android/distribution/UpdateResponseParserTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import org.junit.Assert.assertTrue
88
import org.junit.Before
99
import org.junit.Test
1010
import org.junit.runner.RunWith
11+
import org.robolectric.annotation.Config
1112

1213
@RunWith(AndroidJUnit4::class)
14+
@Config(sdk = [35])
1315
class UpdateResponseParserTest {
1416

1517
private lateinit var options: SentryOptions

0 commit comments

Comments
 (0)