Skip to content

Flutter Gradle plugin rejects AGP Built-in Kotlin version #192167

Description

@wratheus

Steps to reproduce

AGP 9 supports Built-in Kotlin via android.builtInKotlin=true.

When migrating an existing Flutter app to Built-in Kotlin, the Flutter Gradle
plugin rejects the build during configuration:

Error: Your project's Kotlin version (2.2.10) is lower than Flutter's minimum
supported version of 2.2.20.

The version cannot be upgraded independently because Built-in Kotlin is bundled
with AGP. AGP 9.4.0 (latest stable as of 2026-09-02), as well as
9.5.0-alpha03, bundle Kotlin 2.2.10.

Environment:

- Flutter 3.47.2
- AGP 9.3.2
- Gradle 9.7.1
- `android.builtInKotlin=true`

Expected behavior:
Flutter should support AGP Built-in Kotlin, or document a compatible AGP version.
The KGP version validation should not reject a version that is bundled and
controlled by AGP.

Actual behavior:
The build fails while applying dev.flutter.flutter-gradle-plugin, before
project tasks are configured.

Stack trace:
com.flutter.gradle.DependencyVersionChecker.checkKGPVersion

1. Create or migrate a Flutter app to AGP 9.
2. Set android.builtInKotlin=true in android/gradle.properties.
3. Remove org.jetbrains.kotlin.android / kotlin-android from Android Gradle files.
4. Run an Android Gradle task, for example fvm flutter build apk.
5. Observe the Kotlin minimum-version validation failure.
Environment: Flutter 3.47.2, AGP 9.3.2, Gradle 9.7.1.

Expected results

Flutter should support AGP Built-in Kotlin or skip KGP version validation when android.builtInKotlin=true. If a newer AGP is required, Flutter should report the required compatible AGP version.

Actual results

Error: Your project's Kotlin version (2.2.10) is lower than Flutter's
minimum supported version of 2.2.20.
The failure occurs while applying dev.flutter.flutter-gradle-plugin, in:
com.flutter.gradle.DependencyVersionChecker.checkKGPVersion
Built-in Kotlin is provided by AGP, so its version cannot be upgraded independently. AGP 9.4.0 and 9.5.0-alpha03 still bundle Kotlin 2.2.10.

Code sample

Code sample

android/gradle.properties

android.builtInKotlin=true
android.newDsl=false

android/settings.gradle

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "9.3.2" apply false
}

android/app/build.gradle

plugins {
id "com.android.application"
id "dev.flutter.flutter-gradle-plugin"
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.47.2, on macOS 26.6.2 25G83 darwin-arm64, locale en) [379ms]
    • Flutter version 3.47.2 on channel stable at /Users/aleksandrpavlenko/fvm/versions/3.47.2
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d3b14c8769 (6 days ago), 2026-08-26 16:07:51 -0700
    • Engine revision a804b26164
    • Dart version 3.13.2
    • DevTools version 2.60.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets,
      enable-record-use, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration, enable-macos-arm64-only

[!] Android toolchain - develop for Android devices (Android SDK version 37.0.0) [1,025ms]
    • Android SDK at /Users/aleksandrpavlenko/Library/Android/sdk
    • Emulator version 37.1.11.0 (build_id 15917651) (CL:N/A)
    • Platform android-37.1, build-tools 37.0.0
    • Java binary at: /opt/homebrew/opt/openjdk@25/libexec/openjdk.jdk/Contents/Home/bin/java
      This JDK is specified in your Flutter configuration.
      To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment Homebrew (build 25.0.4.1)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/to/macos-android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 26.6) [970ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 17F113
    • CocoaPods version 1.17.0

[✓] Chrome - develop for the web [5ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Connected device (2 available) [10.0s]
    • macOS (desktop) • macos  • darwin-arm64   • macOS 26.6.2 25G83 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 152.0.7977.65
    ! Error: Browsing on the local area network for iPad (Lichi). Ensure the device is unlocked and attached with a cable or associated with the same local area network as
      this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for iPhone Виталя. Ensure the device is unlocked and attached with a cable or associated with the same local area network
      as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for iPhone (Александр). Ensure the device is unlocked and attached with a cable or associated with the same local area
      network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for iPhone 11 lichi. Ensure the device is unlocked and attached with a cable or associated with the same local area network
      as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources [368ms]
    • All expected network resources are available.

! Doctor found issues in 1 category.

Activity

  1. mbcorona commented on Sep 2, 2026

    @mbcorona
    Member

    Hi @wratheus, thanks for the focused report. Routing to the Android team.

    This was also mentioned as one item inside #192111, which has since narrowed to a different AGP 9 bug, so this is the right standalone issue for the built-in Kotlin version problem.

  2. added
    platform-androidAndroid applications specifically
    toolAffects the "flutter" command-line tool. See also t: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-androidOwned by Android platform team
    on Sep 2, 2026
  3. wratheus commented on Sep 2, 2026

    @wratheus
    ContributorAuthor

    Hi @mbcorona, thanks for reply!
    I’d like to add a small clarification.

    As I understand it, there are two different Kotlin versions here, and they are easy to mix up.
    AGP 9.0 uses Kotlin Gradle Plugin 2.2.10 for Built-in Kotlin:
    https://developer.android.com/build/releases/agp-9-0-0-release-notes#runtime-dependency-on-kotlin-gradle-plugin
    Gradle also has its own Embedded Kotlin version:
    https://docs.gradle.org/9.5.0/userguide/compatibility.html
    These are different things.
    Gradle's Embedded Kotlin is used by Gradle/Kotlin DSL, while AGP's KGP is the one used for Built-in Kotlin in Android projects.
    So the 2.3.x version from the Gradle compatibility table does not mean AGP Built-in Kotlin(KGP) is also 2.3.x.

    So.. I can guess that if the android.builtInKotlin=true feature is supported, we should be able to use the KGP version that AGP provides out of the box

    For now, I can see this code. That if check block here probably is not enough when this mentioned feature is enabled

      @VisibleForTesting internal val warnKGPVersion: Version = Version(2, 3, 20)
      @VisibleForTesting internal val errorKGPVersion: Version = Version(2, 2, 20)
    
      <...>
    
      @VisibleForTesting internal fun checkKGPVersion(
              version: Version,
              project: Project
          ) {
              if (version < errorKGPVersion) {
                  val errorMessage: String =
                      getErrorMessage(
                          KGP_NAME,
                          version.toString(),
                          errorKGPVersion.toString(),
                          getPotentialKGPFix(project.rootDir.path)
                      )
                  project.extra.set(OUT_OF_SUPPORT_RANGE_PROPERTY, true)
                  throw DependencyValidationException(errorMessage)
              } else if (version < warnKGPVersion) {
                  <...>
              }
          }

    Also, here is the bug gist, non-null check if KGP is exist, but for some reason we going checkKGPVersion condition and fall with inproriate version. Perhaps this is where we need to refine the logic if the version exists and is passed from AGP with the built-in Kotlin feature.

    @JvmStatic fun checkDependencyVersions(project: Project) {
    <...>
            val kgpVersion: Version? = VersionFetcher.getKGPVersion(project)
            if (kgpVersion != null) {
                checkKGPVersion(kgpVersion, project)
            } else {
                project.logger.debug(
                    "Unable to detect project Kotlin Gradle Plugin version. Skipping Kotlin min-version enforcement. " +
                        "This is expected if the project uses AGP built-in Kotlin (android.builtInKotlin) or does not apply KGP."
                )
            }
    <...>

    source -> https://github.com/flutter/flutter/blob/master/packages/flutter_tools/gradle/src/main/kotlin/DependencyVersionChecker.kt

  4. wratheus commented on Sep 2, 2026

    @wratheus
    ContributorAuthor

    I’m going to submit a focused fix that skips KGP min-version validation when android.builtInKotlin=true, with a regression test.

  5. added
    P1High-priority issues at the top of the work list
    triaged-androidTriaged by Android platform team
    on Sep 8, 2026
  6. added a commit that references this issue on Sep 8, 2026
    05bb83a
  7. github-actions commented on Sep 22, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  8. locked as resolved and limited conversation to collaborators on Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work listhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyteam-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions