Bump AGP to 8.7.0; pin builtInKotlin=false for Flutter 3.44.x#62
Open
ubxty wants to merge 1 commit into
Open
Conversation
Bumps the Android Gradle Plugin pinned in android/build.gradle's
buildscript classpath from 7.3.0 to 8.7.0, matching the direction the
wider Flutter plugin community is moving and lining up with the AGP
versions the example app's settings.gradle.kts already declares.
Also pins android.builtInKotlin=false and android.newDsl=false in the
example's gradle.properties. On Flutter 3.44.x the Flutter Gradle
plugin's detectApplyingKotlinGradlePlugin still calls
pluginManager.apply("kotlin-android") on plugin subprojects during
configuration, and AGP 9.0+ rejects the legacy apply plugin when
builtInKotlin=true. Keeping the legacy apply path working is the
recommended temporary bypass until the project's minimum Flutter
version moves past 3.44 and the Flutter Gradle plugin's built-in
Kotlin detection is updated to skip plugin subprojects.
Other tweaks required to make the build green on Flutter 3.44.1:
- Bumps kotlin_version from 1.7.10 to 2.0.21 so the KGP classpath
matches the Kotlin 2.x toolchain the example app's
settings.gradle.kts declares (1.7.10 fails to resolve on
Kotlin 2.2.20 runtime).
- Switches the example's jvmTarget from JavaVersion.VERSION_11
to the string "11", which the KGP 2.x kotlinOptions extension
requires under the Kotlin DSL.
Verified: `cd example && flutter build apk --debug` produces
build/app/outputs/flutter-apk/app-debug.apk on Flutter 3.44.1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
android/build.gradle'sbuildscript classpath from
7.3.0to8.7.0, matching the directionthe wider Flutter plugin community is moving and lining up with the
AGP versions the example app's
settings.gradle.ktsalready declares.1.7.10to2.0.21so it matches the KGP 2.x toolchain the example app'ssettings.gradle.ktsdeclares.android.builtInKotlin=falseandandroid.newDsl=falsein theexample's
gradle.properties. On Flutter 3.44.x the Flutter Gradleplugin's
detectApplyingKotlinGradlePluginstill callspluginManager.apply("kotlin-android")on plugin subprojects duringconfiguration, and AGP 9.0+ rejects the legacy
apply plugin: "kotlin-android"whenbuiltInKotlin=true. Keepingthe legacy apply path working is the recommended temporary bypass
until the project's minimum Flutter version moves past 3.44.
jvmTargetfromJavaVersion.VERSION_11to the string
"11", which the KGP 2.xkotlinOptionsextensionrequires under the Kotlin DSL.
5.1.1explaining the rationale.Why AGP 8.7.0 (and not 7.3.0 / 9.x)?
The
apply plugin: 'com.android.library'line in the plugin'sandroid/build.gradleis resolved against the buildscript classpathin that file, not the AGP version the consuming app declares. Keeping
that classpath pinned at
7.3.0is a long-standing source ofNoSuchMethodError/com.android.Version.ANDROID_GRADLE_PLUGIN_VERSIONNPEs on AGP 8+ consumer projects. Bumping to
8.7.0keeps the pluginaligned with the AGP 8.7+ versions that modern Flutter apps (including
this example) already pin in their
settings.gradle.kts.Verification
on Flutter 3.44.1, Dart 3.12.1, Gradle 9.4.1, AGP 9.2.0 (the
combination the example app's
settings.gradle.ktspins).Not done in this PR (intentional)
gradle.propertiesdoes not flipandroid.builtInKotlintotrue. The full built-in Kotlin migrationhas to wait for the project's minimum Flutter version to move past
3.44 (the Flutter 3.45+ Flutter Gradle plugin teaches
detectApplyingKotlinGradlePluginto skip plugin subprojects thatset
builtInKotlin=truethemselves).apply plugin: 'kotlin-android'line andkotlinOptionsblock remain in place for the same reason. They will be removed in
the follow-up PR that does the full migration.