Skip to content

AGP 9+: Unconditional Kotlin plugin/kotlin {} usage causes build failures in package Gradle scripts #186795

Description

@daniJimen

Steps to reproduce

Summary
Several package Gradle scripts in this repository currently assume the kotlin-android plugin is always applied and use the kotlin { ... } extension unconditionally. With Android Gradle Plugin (AGP) 9.0+ or AGP configurations where Kotlin is provided as a built-in feature, these assumptions can cause build failures or plugin conflicts.
This issue documents the problem as observed in the branch where buildscript changes were made, and provides reproduction steps and diagnostic details so maintainers can verify the failure. This issue does NOT propose a fix — it only documents the behavior and how to reproduce it.
Affected files / packages (representative)
A total of 55 .gradle.kts files were touched in the branch where this was observed. Representative library/platform packages (where the issue is most important) include:

  • packages/camera/camera_android_camerax — android/build.gradle.kts
  • packages/file_selector/file_selector_android — android/build.gradle.kts
  • packages/google_maps_flutter/google_maps_flutter_android — android/build.gradle.kts
  • packages/google_sign_in/google_sign_in_android — android/build.gradle.kts
  • packages/image_picker/image_picker_android — android/build.gradle.kts
  • packages/in_app_purchase/in_app_purchase_android — android/build.gradle.kts
  • packages/interactive_media_ads — android/build.gradle.kts
  • packages/local_auth/local_auth_android — android/build.gradle.kts
  • packages/quick_actions/quick_actions_android — android/build.gradle.kts
  • packages/shared_preferences/shared_preferences_android — android/build.gradle.kts
  • packages/url_launcher/url_launcher_android — android/build.gradle.kts
  • packages/video_player/video_player_android — android/build.gradle.kts
  • packages/webview_flutter/webview_flutter_android — android/build.gradle.kts

Additionally, many example/android/app/build.gradle.kts files and other example modules were modified in the branch.
Environment and when this occurs
AGP 9.0+ or an AGP configuration where Kotlin is provided as a built-in plugin.
Gradle Kotlin DSL scripts (build.gradle.kts) that:
Have id("org.jetbrains.kotlin.android") applied unconditionally in plugins {} or
Configure the kotlin { ... } extension unconditionally while not guaranteeing that the kotlin extension is present at configuration time.
Reproducible when building example or library Android modules that depend on affected packages.

How to reproduce (minimal steps)

  • Ensure you have a checkout of this repository branch with the affected build.gradle.kts changes (or reproduce by making an unconditional kotlin {} usage in any package/example).
  • Use an Android Gradle Plugin 9.x toolchain in an Android project that consumes one of the affected packages. Example ways to test:
  • Create or use an Android app referencing one of the affected packages (e.g., packages/image_picker/image_picker_android example app).
  • Configure the app's Gradle wrapper and build.gradle.kts to use an AGP 9.x-compatible Gradle distribution/tooling.
  • From the example app directory (or project root), run a Gradle assemble task:

From the example Android app directory

./gradlew assembleDebug --stacktrace

or from the repository root for a specific example:
cd packages/image_picker/example
./gradlew :app:assembleDebug --stacktrace

Observe configuration-time failures or plugin-related errors matching the symptoms above. Pay attention to errors mentioning missing kotlin properties or plugin conflicts.

Additional diagnostic notes
The problem is triggered by build.gradle.kts code that assumes the kotlin extension exists or that org.jetbrains.kotlin.android is always applied.
When AGP provides Kotlin as a built-in plugin, the explicit plugin and unconditional extension configuration may be unnecessary or may execute in a sequence that causes the kotlin extension to be unavailable at configuration time.
The branch where these issues were inspected contains changes to many .gradle.kts files; maintainers may want to scan those files to see where kotlin { ... } blocks appear unconditionally or where id("org.jetbrains.kotlin.android") is enforced in plugins {}.

triage: bug
area: android
priority: medium

Expected results

Projects using AGP 9.0+ (or AGP configurations that provide built-in Kotlin) should build successfully with the packages and their examples.
Gradle should not fail due to missing kotlin extension or plugin conflicts, and examples should assemble normally.

Actual results

When building with AGP 9.0+ (or when AGP provides Kotlin as built-in), the following symptoms may appear:
Gradle configuration-time failure indicating the kotlin extension is missing, e.g.:
Exception message similar to: "Could not get unknown property 'kotlin' for project ':app' of type org.gradle.api.Project."
Or plugin application conflicts / duplicate plugin warnings/errors when kotlin-android is explicitly applied while AGP already provides Kotlin.
CI or local builds fail for example modules that reference affected packages.
Example reproduction error (representative)
Example messages seen in similar circumstances (format may vary by Gradle/AGP version):
"A problem occurred configuring project ':app'.
Could not get unknown property 'kotlin' for project ':app' of type org.gradle.api.Project."
Or plugin conflict / duplicate plugin diagnostics from Gradle/AGP during the configuration phase.

Code sample

Code sample
# This builtInKotlin flag was added automatically by Flutter migrator
android.builtInKotlin=false
# This newDsl flag was added automatically by Flutter migrator
android.newDsl=false

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
WARNING: Your Android app project: app located at: /Users/user/developer/flutter/flutter_packages/packages/packages/flutter_plugin_android_lifecycle/example/android/app/build.gradle.kts
applies the Kotlin Gradle Plugin, which will cause build failures in future versions of Flutter. 
Please migrate your app to Built-in Kotlin using this guide: https://docs.flutter.dev/release/breaking-changes/migrate-to-built-in-kotlin/for-app-developers

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.44.0, on macOS 26.4.1 25E253 darwin-arm64, locale es-ES)
[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0)
[✓] Xcode - develop for iOS and macOS (Xcode 26.5)
[✓] Chrome - develop for the web
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work list

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions