From 34be47db82f6a638d105add4ca949d87388de888 Mon Sep 17 00:00:00 2001 From: Mikkeli Date: Sun, 23 Aug 2026 11:56:29 +0900 Subject: [PATCH] build(android): move to Flutter 3.47 template toolchain (Gradle 9.3.1 / AGP 9.1.0 / Kotlin 2.4.0) The project pinned Gradle 8.12 / AGP 8.9.1 / Kotlin 2.1.0, all three below the hard error floors that Flutter 3.47.1 enforces in DependencyVersionChecker.kt (8.14.0 / 8.11.1 / 2.2.20). Nothing here had rotted; the SDK moved. Targets Flutter's own template defaults rather than the lowest combo that clears the floors, because Flutter promotes its warn floor to the error floor in the very next release -- clearing only the hard floor buys one release of runway. `flutter-android-preflight` on the host re-derives all of this from the installed SDK. Also: - kotlinOptions{} -> kotlin{compilerOptions{}}: the old DSL is a script COMPILATION error under Kotlin >= 2.3, not a warning. - Java/jvmTarget 11 -> 17. - Drop android.enableJetifier (obsolete, removed outright in AGP 9). Keep the migrator's builtInKotlin=false: builtInKotlin=true makes AGP 9.1.0 supply Kotlin 2.2.10, BELOW Flutter's own 2.2.20 floor, so Flutter rejects its own recommendation. This app has no native plugins, so it needed none of the pub-plugin workarounds gps-speedo did. Verified: flutter build apk --debug and --release, as both mikkeli and hermes. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_016dKAqFo9Uj3mPZWvDzj3G8 --- analysis_options.yaml | 9 +++++++++ android/app/build.gradle.kts | 16 ++++++++++------ android/gradle.properties | 5 ++++- android/gradle/wrapper/gradle-wrapper.properties | 2 +- android/settings.gradle.kts | 4 ++-- pubspec.lock | 14 +++++++------- 6 files changed, 33 insertions(+), 17 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 0d29021..bf8d421 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -7,6 +7,15 @@ # The following line activates a set of recommended lints for Flutter apps, # packages, and plugins designed to encourage good coding practices. +analyzer: + exclude: + - build/** + - android/** + - ios/** + - web/** + - windows/** + - macos/** + - linux/** include: package:flutter_lints/flutter.yaml linter: diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index a9c4063..bbd703b 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + plugins { id("com.android.application") id("kotlin-android") @@ -11,12 +13,8 @@ android { ndkVersion = flutter.ndkVersion compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } - - kotlinOptions { - jvmTarget = JavaVersion.VERSION_11.toString() + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } defaultConfig { @@ -39,6 +37,12 @@ android { } } +kotlin { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) + } +} + flutter { source = "../.." } diff --git a/android/gradle.properties b/android/gradle.properties index f018a61..d5da727 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,3 +1,6 @@ org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true -android.enableJetifier=true +# This builtInKotlin flag was added automatically by Flutter migrator +android.builtInKotlin=false +# This newDsl flag was added automatically by Flutter migrator +android.newDsl=false diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index ac3b479..a20f2c4 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-all.zip diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts index fb605bc..b28021a 100644 --- a/android/settings.gradle.kts +++ b/android/settings.gradle.kts @@ -19,8 +19,8 @@ pluginManagement { plugins { id("dev.flutter.flutter-plugin-loader") version "1.0.0" - id("com.android.application") version "8.9.1" apply false - id("org.jetbrains.kotlin.android") version "2.1.0" apply false + id("com.android.application") version "9.1.0" apply false + id("org.jetbrains.kotlin.android") version "2.4.0" apply false } include(":app") diff --git a/pubspec.lock b/pubspec.lock index 789c76b..a7e7157 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -84,10 +84,10 @@ packages: dependency: transitive description: name: intl - sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5" + sha256: "1ca20c894b1717686a2319b8548763d812bc0aabdac580420a44c5178c57a867" url: "https://pub.dev" source: hosted - version: "0.20.2" + version: "0.20.3" leak_tracker: dependency: transitive description: @@ -124,10 +124,10 @@ packages: dependency: transitive description: name: matcher - sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + sha256: "31bd099b47c10cd1aeb55146a2d46ce0277630ecef3f7dae54ad7873f36696cd" url: "https://pub.dev" source: hosted - version: "0.12.17" + version: "0.12.20" material_color_utilities: dependency: "direct overridden" description: @@ -209,10 +209,10 @@ packages: dependency: transitive description: name: vector_math - sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + sha256: f36f9f3be64c6198714492bb455c11056e33e2f85d9a0b676a48301e44fdcf47 url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.4.2" vm_service: dependency: transitive description: @@ -222,5 +222,5 @@ packages: source: hosted version: "15.0.2" sdks: - dart: ">=3.9.0 <4.0.0" + dart: ">=3.11.0-0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54"