Skip to content

Commit 0f94ec7

Browse files
runningcodeclaude
andcommitted
build: Bump AGP to 9.2.1 and migrate Android modules (JAVA-649)
Raise the minimum AGP to 9.1.1 (default fallback 9.2.1) and perform the AGP 9 migration: refresh the AGP-compat matrix, 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, bump the uitest modules to JVM 11, and resolve the AGP 9.2 lint findings. 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 455eb6e commit 0f94ec7

23 files changed

Lines changed: 108 additions & 39 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.1.1', '9.2.0', '9.2.1' ]
2121
integrations: [ true, false ]
2222

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

build.gradle.kts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ subprojects {
168168
}
169169
}
170170

171+
// AGP 9 defaults Android modules to Java 11. Pin the published library modules back
172+
// to Java 8 so their bytecode stays consumable by Java 8 projects, mirroring the
173+
// java-library pin above.
174+
plugins.withId("com.android.library") {
175+
configure<com.android.build.gradle.BaseExtension> {
176+
compileOptions {
177+
sourceCompatibility = JavaVersion.VERSION_1_8
178+
targetCompatibility = JavaVersion.VERSION_1_8
179+
}
180+
}
181+
}
182+
171183
apply<MavenPublishPlugin>()
172184

173185
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-fragment/build.gradle.kts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import io.gitlab.arturbosch.detekt.Detekt
2+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
3+
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
24

35
plugins {
46
id("com.android.library")
@@ -23,10 +25,14 @@ android {
2325
getByName("release") { consumerProguardFiles("proguard-rules.pro") }
2426
}
2527

28+
// AGP 9 only generates unit tests for the testBuildType. CI disables the debug
29+
// variant, so unit tests must target release to run at all.
30+
testBuildType = "release"
31+
2632
kotlin {
27-
compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
28-
compilerOptions.languageVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9
29-
compilerOptions.apiVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9
33+
compilerOptions.jvmTarget = JvmTarget.JVM_1_8
34+
compilerOptions.languageVersion = KotlinVersion.KOTLIN_1_9
35+
compilerOptions.apiVersion = KotlinVersion.KOTLIN_1_9
3036
}
3137

3238
testOptions {

sentry-android-integration-tests/sentry-uitest-android-benchmark/build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import io.gitlab.arturbosch.detekt.Detekt
22
import net.ltgt.gradle.errorprone.errorprone
3+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
34

45
plugins {
56
id("com.android.application")
@@ -64,12 +65,12 @@ android {
6465
}
6566
}
6667

67-
kotlin { compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8 }
68+
kotlin { compilerOptions.jvmTarget = JvmTarget.JVM_11 }
6869

6970
lint {
7071
warningsAsErrors = true
7172
checkDependencies = true
72-
// Suppress OldTargetApi: lint 8.13.1 expects API 37 but we target 36
73+
// Suppress OldTargetApi: lint 9.2.1 expects API 37 but we target 36
7374
disable += "OldTargetApi"
7475

7576
// We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks.

0 commit comments

Comments
 (0)