Skip to content

Commit fa05d67

Browse files
committed
build: migrate to AGP 9.0
The kotlin compiler injects null checks into every function to gurantee null-safety. With AGP 9.0, R8 is able to optimize them away, resulting in a minor performance improvement and smaller binary (~9.4 megabytes to ~9.0 megabytes). However, we need to use the baselineprofile alpha, as the current release does not yet work with the new dsl. Ref: https://issuetracker.google.com/issues/443311090 Ref: https://rahulrav.com/blog/kotlin_intrinsics_on_android.html
1 parent 66c2efa commit fa05d67

5 files changed

Lines changed: 18 additions & 14 deletions

File tree

app/build.gradle.kts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import java.util.Properties
2+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
23

34
plugins {
45
id("com.android.application")
5-
id("kotlin-android")
66
id("kotlinx-serialization")
77
id("kotlin-parcelize")
88
id("androidx.navigation.safeargs.kotlin")
@@ -82,8 +82,11 @@ android {
8282
targetCompatibility = JavaVersion.VERSION_17
8383
}
8484

85-
kotlinOptions {
86-
jvmTarget = "17"
85+
kotlin {
86+
compilerOptions {
87+
jvmTarget = JvmTarget.JVM_17
88+
javaParameters = true
89+
}
8790
}
8891

8992
packaging {
@@ -99,6 +102,7 @@ android {
99102

100103
buildFeatures {
101104
buildConfig = true
105+
resValues = true
102106
}
103107

104108
dependenciesInfo {

baselineprofile/build.gradle.kts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
13
plugins {
24
alias(libs.plugins.androidTest)
3-
alias(libs.plugins.jetbrainsKotlinAndroid)
45
alias(libs.plugins.baselineprofile)
56
}
67

@@ -13,8 +14,10 @@ android {
1314
targetCompatibility = JavaVersion.VERSION_17
1415
}
1516

16-
kotlinOptions {
17-
jvmTarget = "17"
17+
kotlin {
18+
compilerOptions {
19+
jvmTarget = JvmTarget.JVM_17
20+
}
1821
}
1922

2023
defaultConfig {

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ allprojects {
2727

2828
plugins {
2929
alias(libs.plugins.androidTest) apply false
30-
alias(libs.plugins.jetbrainsKotlinAndroid) apply false
3130
alias(libs.plugins.baselineprofile) apply false
3231
alias(libs.plugins.androidApplication) apply false
3332
}

gradle.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
1414
# Kotlin code style for this project: "official" or "obsolete":
1515
kotlin.code.style=official
1616
android.useAndroidX=true
17-
android.enableJetifier=true
1817
android.nonTransitiveRClass=true
1918
android.nonFinalResIds=true
2019
org.gradle.parallel=true

gradle/libs.versions.toml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
appcompat = "1.7.1"
33
core = "1.13.1"
44
documentfile = "1.1.0"
5-
gradle = "8.6.1"
5+
gradle = "9.0.1"
66
junit = "4.13.2"
7-
kotlin = "1.9.25"
8-
ksp = "1.9.25-1.0.20"
7+
kotlin = "2.3.10"
8+
ksp = "2.3.5"
99
lifecycle = "2.8.7"
1010
constraintlayout = "2.2.1"
1111
loggingInterceptor = "4.12.0"
1212
material = "1.14.0-alpha09"
13-
navigation = "2.8.9"
13+
navigation = "2.9.7"
1414
newpipeextractor = "fc63085"
1515
preference = "1.2.1"
1616
extJunit = "1.3.0"
@@ -28,7 +28,7 @@ activity = "1.9.3"
2828
fragment = "1.8.9"
2929
uiautomator = "2.3.0"
3030
benchmarkMacroJunit4 = "1.4.1"
31-
baselineprofile = "1.4.1"
31+
baselineprofile = "1.5.0-alpha03"
3232
profileinstaller = "1.4.1"
3333
paging = "3.4.0"
3434
collection = "1.5.0"
@@ -85,7 +85,6 @@ androidx-swiperefreshlayout = { group = "androidx.swiperefreshlayout", name = "s
8585

8686
[plugins]
8787
androidTest = { id = "com.android.test", version.ref = "gradle" }
88-
jetbrainsKotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
8988
baselineprofile = { id = "androidx.baselineprofile", version.ref = "baselineprofile" }
9089
androidApplication = { id = "com.android.application", version.ref = "gradle" }
9190
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }

0 commit comments

Comments
 (0)