Skip to content

Incompatability with Android Gradle Plugin (AGP) 9.0+ breaks Android Build #1942

Description

@Phylu

Describe the bug
The file_picker plugin (version 10.3.8) is incompatible with Android Gradle Plugin (AGP) 9.0+ due to applying the deprecated kotlin-android plugin. AGP 9.0 introduced built-in Kotlin support and automatically registers a kotlin extension. When file_picker's build.gradle tries to apply plugin: 'kotlin-android', it attempts to create a duplicate kotlin extension, causing the build to fail with IllegalArgumentException: Cannot add extension with name 'kotlin', as there is an extension already registered with that name.

This issue blocks projects from upgrading to AGP 9.0, which is the current stable version as of January 2026.

Platform

  • Android
  • iOS
  • Web
  • Desktop

Platform OS version

  • Android Gradle Plugin (AGP): 9.0.0
  • Gradle: 8.13
  • Kotlin: 2.1.0 (built-in with AGP 9.0)
  • compileSdk: 36

How are you picking?
The issue occurs during build configuration, before any file picking code runs. Any usage of the plugin triggers the build error.

Details to reproduce the issue

  1. Create a Flutter project with file_picker: ^10.3.8 in pubspec.yaml
  2. Update Android configuration to use AGP 9.0+:
    • In android/settings.gradle: Set id "com.android.application" version "9.0.0"
    • In android/app/build.gradle: Remove the kotlin-android plugin (as per AGP 9.0 migration guide)
  3. Run flutter build apk or flutter run
  4. Build fails during project evaluation with the error below

Error Log

Build file '/Users/Phylu/.pub-cache/hosted/pub.dev/file_picker-10.3.8/android/build.gradle' line: 27

A problem occurred evaluating project ':file_picker'.
> Failed to apply plugin 'org.jetbrains.kotlin.android'.
   > Cannot add extension with name 'kotlin', as there is an extension already registered with that name.

Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin 'org.jetbrains.kotlin.android'.
	at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:176)
	...
Caused by: java.lang.IllegalArgumentException: Cannot add extension with name 'kotlin', as there is an extension already registered with that name.
	at org.gradle.internal.extensibility.ExtensionsStorage.add(ExtensionsStorage.java:40)
	at org.gradle.internal.extensibility.DefaultExtensionContainer.add(DefaultExtensionContainer.java:78)
	at org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtensionKt.createKotlinExtension(KotlinProjectExtension.kt:44)
	at org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper.apply(KotlinPluginWrapper.kt:221)
	at org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper.apply(PluginWrappers.kt:34)
	...

Flutter Version details

[✓] Flutter (Channel stable, 3.38.7, on macOS 15.7.3 24G419 darwin-x64, locale en-DE) [4.3s]
    • Flutter version 3.38.7 on channel stable at /usr/local/Caskroom/flutter/3.29.2/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 3b62efc2a3 (vor 9 Tagen), 2026-01-13 13:47:42 -0800
    • Engine revision 78fc3012e4
    • Dart version 3.10.7
    • DevTools version 2.51.1
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations,
      enable-native-assets, omit-legacy-version-file, enable-lldb-debugging

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [13.2s]
    • Android SDK at /Users/janosch/Library/Android/sdk
    • Emulator version 36.3.10.0 (build_id 14472402) (CL:N/A)
    • Platform android-36, build-tools 36.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.8+-14196175-b1038.72)
    • All Android licenses accepted.

Additional context

As a workaround, I can use the following configuration in the settings.gradle file (and keeping the explicit kotlin and flutter plugin versions), to use the package with the new system:

android.builtInKotlin=false

Metadata

Metadata

Assignees

Labels

feature-candidateThis issue might result in a feature to be implemented

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions