Summary
On AGP 9 with android.builtInKotlin=false, workmanager_android cannot be built. Both the current
and the previous release fail, in different ways.
android.builtInKotlin=false is the value Flutter writes by default (flutter/flutter#183910), and
its Android migrator restores it if removed. The AGP 9 handling added after #710 branches on the AGP
major version alone, so it assumes built-in Kotlin is enabled — which, on a default Flutter project,
it is not.
Setting the flag to true is not a general workaround: other plugins still require the legacy path.
Environment
|
|
| Flutter |
3.44.8 (stable, 058e0af2c2) |
| Dart |
3.12.2 |
| AGP |
9.0.1 |
| Gradle |
9.1.0 |
| KGP |
2.3.20 (apply false, per the Flutter template) |
| Host |
macOS 26.5.2, Apple Silicon |
android/gradle.properties, as generated and maintained by Flutter:
android.useAndroidX=true
android.newDsl=false
android.builtInKotlin=false
Failure 1 — workmanager_android 0.10.4
* What went wrong:
A problem occurred evaluating project ':workmanager_android'.
> Could not find method kotlin() for arguments [...] on project ':workmanager_android'
of type org.gradle.api.Project.
Build file '.../workmanager_android-0.10.4/android/build.gradle' line: 60
android/build.gradle branches on the AGP major version only:
def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int
if (agpMajor < 9) {
apply plugin: 'kotlin-android'
}
…
if (agpMajor >= 9) {
kotlin { // line 60
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
}
}
}
With AGP 9 and built-in Kotlin disabled, neither branch supplies a kotlin extension: KGP is not
applied, and AGP does not contribute one. Evaluation fails.
Failure 2 — workmanager_android 0.9.3
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> .../GeneratedPluginRegistrant.java:94: error: cannot find symbol
flutterEngine.getPlugins().add(new dev.fluttercommunity.workmanager.WorkmanagerPlugin());
^
symbol: class WorkmanagerPlugin
Same if (agpMajor < 9) guard, no kotlin {} block: the script evaluates, but no Kotlin plugin is
applied, the module's Kotlin sources are never compiled, and the plugin class does not exist at
registration. This matches #710, reported there against 0.10.1 / AGP 9.2.1.
Why android.builtInKotlin=true is not a workaround
Plugins that still apply KGP then fail instead. For example, with app_links 7.2.1 present
(a common transitive dependency):
* What went wrong:
An exception occurred applying plugin request [id: 'com.android.library']
> Failed to apply plugin 'com.android.internal.library'.
> java.lang.IllegalStateException: The 'org.jetbrains.kotlin.android' plugin is no longer
required for Kotlin support since AGP 9.0.
Removing the org.jetbrains.kotlin.android declaration from settings.gradle.kts does not help.
Deleting the property from gradle.properties does not persist — Flutter's migrator rewrites it:
# This builtInKotlin flag was added automatically by Flutter migrator
android.builtInKotlin=false
Setting it explicitly to true is respected; leaving it absent is not.
Minimal reproduction
flutter create a project with Flutter 3.44.8 (AGP 9.0.1, builtInKotlin=false by default).
- Add
workmanager: ^0.10.5.
flutter build apk --debug → Failure 1.
- Change to
workmanager: ^0.9.0, flutter build apk --debug → Failure 2.
- Add any plugin that still applies KGP (e.g.
app_links), set android.builtInKotlin=true,
rebuild → third failure above.
Proposed fix
Condition on both axes rather than on the AGP version alone. flutter_timezone 5.1.0 already does
this:
def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int
def builtInKotlinEnabled = /* read android.builtInKotlin */
if (agpMajor < 9 || !builtInKotlinEnabled) {
apply plugin: 'kotlin-android'
}
Applying the same condition to both the apply plugin guard and the kotlin {} block would make
the module build under either setting, with no behaviour change for projects already migrated.
Confirmation
With workmanager removed and no other change, both platform builds are clean on the configuration
above:
✓ Built build/app/outputs/flutter-apk/app-debug.apk
✓ Built build/ios/iphoneos/Runner.app
iOS is unaffected throughout — workmanager_apple builds correctly once the deployment target is
raised from 13.0 to 14.0.
Related: #710, flutter/flutter#183910.
Summary
On AGP 9 with
android.builtInKotlin=false,workmanager_androidcannot be built. Both the currentand the previous release fail, in different ways.
android.builtInKotlin=falseis the value Flutter writes by default (flutter/flutter#183910), andits Android migrator restores it if removed. The AGP 9 handling added after #710 branches on the AGP
major version alone, so it assumes built-in Kotlin is enabled — which, on a default Flutter project,
it is not.
Setting the flag to
trueis not a general workaround: other plugins still require the legacy path.Environment
apply false, per the Flutter template)android/gradle.properties, as generated and maintained by Flutter:Failure 1 —
workmanager_android0.10.4android/build.gradlebranches on the AGP major version only:With AGP 9 and built-in Kotlin disabled, neither branch supplies a
kotlinextension: KGP is notapplied, and AGP does not contribute one. Evaluation fails.
Failure 2 —
workmanager_android0.9.3Same
if (agpMajor < 9)guard, nokotlin {}block: the script evaluates, but no Kotlin plugin isapplied, the module's Kotlin sources are never compiled, and the plugin class does not exist at
registration. This matches #710, reported there against 0.10.1 / AGP 9.2.1.
Why
android.builtInKotlin=trueis not a workaroundPlugins that still apply KGP then fail instead. For example, with
app_links7.2.1 present(a common transitive dependency):
Removing the
org.jetbrains.kotlin.androiddeclaration fromsettings.gradle.ktsdoes not help.Deleting the property from
gradle.propertiesdoes not persist — Flutter's migrator rewrites it:Setting it explicitly to
trueis respected; leaving it absent is not.Minimal reproduction
flutter createa project with Flutter 3.44.8 (AGP 9.0.1,builtInKotlin=falseby default).workmanager: ^0.10.5.flutter build apk --debug→ Failure 1.workmanager: ^0.9.0,flutter build apk --debug→ Failure 2.app_links), setandroid.builtInKotlin=true,rebuild → third failure above.
Proposed fix
Condition on both axes rather than on the AGP version alone.
flutter_timezone5.1.0 already doesthis:
Applying the same condition to both the
apply pluginguard and thekotlin {}block would makethe module build under either setting, with no behaviour change for projects already migrated.
Confirmation
With
workmanagerremoved and no other change, both platform builds are clean on the configurationabove:
iOS is unaffected throughout —
workmanager_applebuilds correctly once the deployment target israised from 13.0 to 14.0.
Related: #710, flutter/flutter#183910.