fix(mobile-app): resolve Kotlin build errors in build.gradle.kts

- Rename getAutoVersionCode() to calculateNextVersionCode() to avoid
  JVM signature clash with auto-generated property getter
- Remove unnecessary Elvis operator for non-nullable flutter.versionName
- Migrate deprecated kotlinOptions.jvmTarget to kotlin.jvmToolchain DSL

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-09 01:07:58 -08:00
parent a86131471c
commit 15f617c9a9
1 changed files with 5 additions and 5 deletions

View File

@ -22,7 +22,7 @@ if (keyPropertiesFile.exists()) {
val versionPropertiesFile = rootProject.file("app/version.properties") val versionPropertiesFile = rootProject.file("app/version.properties")
val versionProperties = Properties() val versionProperties = Properties()
fun getAutoVersionCode(): Int { fun calculateNextVersionCode(): Int {
if (versionPropertiesFile.exists()) { if (versionPropertiesFile.exists()) {
versionProperties.load(FileInputStream(versionPropertiesFile)) versionProperties.load(FileInputStream(versionPropertiesFile))
} }
@ -34,12 +34,12 @@ fun getAutoVersionCode(): Int {
} }
// Get auto-incremented version code // Get auto-incremented version code
val autoVersionCode = getAutoVersionCode() val autoVersionCode = calculateNextVersionCode()
// Version name format: major.minor.patch (from pubspec.yaml) + build number // Version name format: major.minor.patch (from pubspec.yaml) + build number
// Example: 1.0.0.123 // Example: 1.0.0.123
fun getAutoVersionName(): String { fun getAutoVersionName(): String {
val flutterVersionName = flutter.versionName ?: "1.0.0" val flutterVersionName = flutter.versionName
return "$flutterVersionName.$autoVersionCode" return "$flutterVersionName.$autoVersionCode"
} }
@ -53,8 +53,8 @@ android {
targetCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17
} }
kotlinOptions { kotlin {
jvmTarget = JavaVersion.VERSION_17.toString() jvmToolchain(17)
} }
defaultConfig { defaultConfig {