workmanager_android: guarded apply plugin: 'kotlin-android' is the pattern Flutter says will stop building (flutter/flutter#189770)
Version
| Technology | Version |
|---|---|
| workmanager | 0.10.10 |
| workmanager_android | 0.10.9 |
| Flutter | 3.47.5 (6a19cca564) |
| Android Gradle Plugin | 9.4.1 |
| Gradle | 9.7.1 |
Describe the error
With android.builtInKotlin=true in the app's gradle.properties, every Android build prints:
WARNING: Your app uses the following plugins that apply Kotlin Gradle Plugin (KGP): workmanager_android
Future versions of Flutter will fail to build if your app uses plugins that apply KGP.
At runtime the plugin does not apply KGP: the guard added in #721 / #722 skips it. I checked with an init script over every project, and plugins.hasPlugin('org.jetbrains.kotlin.android') is false for workmanager_android. The warning comes from Flutter's detectApplyingKotlinGradlePlugin, which regex-matches the guarded apply plugin: 'kotlin-android' line in android/build.gradle.
This isn't a Flutter bug they plan to fix. They closed flutter/flutter#189770 on 2026-10-02 as intended behaviour. They now discourage the guarded pattern, removed it from their docs, and say it will fail to build once their regex is fixed (closing comment). The guidance there is to follow the direct migration for plugin authors.
The case the guard exists for (an app that keeps android.builtInKotlin=false, Flutter's default) appears to be handled by Flutter itself now. On 3.47.5, FlutterPluginUtils.detectApplyingKotlinGradlePlugin applies kotlin-android to any plugin subproject that doesn't apply it when built-in Kotlin is off (source). So dropping the guard and the apply plugin: 'kotlin-android' line entirely, and keeping the kotlin { compilerOptions { ... } } block, may cover both cases. I haven't checked which minimum Flutter version you support, or whether older versions have that fallback.
Repro
- A Flutter 3.47.5 app on AGP 9.x depending on
workmanager: ^0.10.10. - Set
android.builtInKotlin=trueinandroid/gradle.properties. flutter build apk --debug. The warning above listsworkmanager_android.
Confirmed on our app as well.
- Flutter 3.47.6 stable
- AGP 9.0.1 / Gradle 9.1.0
- workmanager 0.9.0+3 / workmanager_android 0.9.0+2
flutter run continues to list workmanager_android as applying KGP. We cannot migrate the app to Built-in Kotlin because Flutter currently rejects its detected AGP built-in Kotlin 2.2.10 as lower than the >= 2.2.20 it requires. Please remove the KGP declaration/guard pattern as described in this issue so consumers are not blocked by the forthcoming Flutter removal.
We see the same with workmanager 0.10.10 (workmanager_android 0.10.9), Flutter 3.47.9, AGP 9.5.0 and android.builtInKotlin=true. Because flutter/flutter#189770 says that this pattern will fail in a future Flutter release, is there an ETA for a fix? I see that #744 was closed without a merge.
Same warning here with Flutter 3.47.7, AGP 9.1.0 and Kotlin 2.4.0 on workmanager_android 0.10.9. Flutter's check (flutter/flutter#189770) matches the apply plugin: 'kotlin-android' line in android/build.gradle as text, so the warning appears even though that line sits inside the if and is skipped when built-in Kotlin is on. In a local copy of the plugin we removed that conditional block and kept only the kotlin { compilerOptions { ... } } block: Gradle configuration succeeds without the warning with android.builtInKotlin=false, and a release arm64 APK builds with android.builtInKotlin=true. Would you accept a PR with that change?
Another reproduction, with a minimal project and evidence that KGP is not actually applied:
- Flutter 3.47.9 (stable), Dart 3.13.7
- AGP 9.1.1, Gradle 9.3.1, Kotlin 2.4.21,
android.builtInKotlin=true - workmanager 0.10.10 / workmanager_android 0.10.9 (latest)
Steps: flutter create --platforms=android kgprepro, flutter pub add workmanager:0.10.10, set android.builtInKotlin=true in android/gradle.properties, AGP 9.1.1 and Kotlin 2.4.21 in settings.gradle.kts, then flutter build apk --debug. The build succeeds and prints:
WARNING: Your app uses the following plugins that apply Kotlin Gradle Plugin (KGP): firebase_analytics, firebase_core, workmanager_android
Future versions of Flutter will fail to build if your app uses plugins that apply KGP.
An init script printing plugins.hasPlugin('org.jetbrains.kotlin.android') after evaluation reports :workmanager_android kotlin-android applied: false. So the guard works at runtime, and the warning comes from Flutter's text match on the guarded apply plugin: 'kotlin-android' line. Given flutter/flutter#189770's closing note that this pattern will fail to build once the regex is fixed, a release that removes or restructures the fallback would help. The same report has been filed for FlutterFire, which uses the same guard: https://github.com/firebase/flutterfire/issues/18944