Android: build on JDK 25 with Gradle 9.6.1, AGP 9.4.1, Kotlin 2.2.10

Android Studio now bundles JBR 25, which Gradle 8.14's embedded Kotlin
can't parse. Follow Tauri's current template: Gradle 9.6.1, Kotlin 2.2.10,
the builtInKotlin/newDsl/failOnMissingFiles compatibility flags, the
compilerOptions DSL, and ExecOperations in BuildTask (project.exec is gone
in Gradle 9). AGP goes to 9.4.1 rather than the template's 9.3.1.

Release lint vital is turned off: AGP 9.3/9.4's lint crashes analysing the
.gradle.kts scripts (findFirCompiledSymbol), failing every release build.

The env scripts now accept JDK 17 through 25, preferring Studio's JBR.
This commit is contained in:
2026-10-16 22:39:36 -05:00
parent 89378a41fb
commit 1641d9aa47
10 changed files with 96 additions and 61 deletions

View File

@@ -1,5 +1,6 @@
import java.io.FileInputStream
import java.util.Properties
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
id("com.android.application")
@@ -60,18 +61,35 @@ android {
signingConfigs.findByName("release")?.let { signingConfig = it }
isMinifyEnabled = true
proguardFiles(
*fileTree(".") { include("**/*.pro") }
*fileTree(".") {
include("**/*.pro")
exclude("build/**")
}
.plus(getDefaultProguardFile("proguard-android-optimize.txt"))
.toList().toTypedArray()
)
}
}
kotlinOptions {
jvmTarget = "1.8"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
buildFeatures {
buildConfig = true
}
// AGP 9.3/9.4's lint crashes analysing the .gradle.kts scripts
// ("findFirCompiledSymbol only works on compiled declarations"), which
// fails every release build. Skip the release-time lint pass until a
// newer AGP fixes it.
lint {
checkReleaseBuilds = false
}
}
kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_1_8
}
}
rust {