Skip to content

fix: apply kotlin-android plugin explicitly for KGP 2.x compatibility#25

Open
lalpix wants to merge 1 commit into
mway-io:masterfrom
lalpix:fix/kgp-2x-kotlin-options
Open

fix: apply kotlin-android plugin explicitly for KGP 2.x compatibility#25
lalpix wants to merge 1 commit into
mway-io:masterfrom
lalpix:fix/kgp-2x-kotlin-options

Conversation

@lalpix

@lalpix lalpix commented Jun 30, 2026

Copy link
Copy Markdown

Problem

kotlinOptions {} inside the android {} block requires the Kotlin Android plugin (kotlin-android) to be applied. Previously this worked implicitly via Flutter tooling, but Kotlin Gradle Plugin 2.x no longer registers the kotlinOptions extension on the android extension unless the plugin is explicitly applied.

This causes the following build error when using the package with KGP 2.0+:

Could not find method kotlinOptions() for arguments [...] on extension 'android'
of type com.android.build.gradle.LibraryExtension.

Fix

  • Explicitly apply kotlin-android plugin in android/build.gradle
  • Remove the kotlinOptions block — jvmTarget is already covered by the compileOptions sourceCompatibility setting which AGP propagates to Kotlin automatically

Tested with

  • Kotlin Gradle Plugin 2.1.0
  • Android Gradle Plugin 8.12.0

kotlinOptions {} in the android {} block requires the Kotlin Android
plugin to be applied. Previously this worked implicitly via the Flutter
tooling, but Kotlin Gradle Plugin 2.x no longer registers the
kotlinOptions extension on android {} unless kotlin-android is applied
explicitly. The jvmTarget is now set via compileOptions sourceCompatibility
which AGP propagates automatically.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant