Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .fvmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"flutter": "3.44.8"
"flutter": "3.47.7"
}
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Code & test conventions (previously in `CLAUDE.md`) are consolidated in the last

## Android / AGP facts
- AGP 9 enables built-in Kotlin **by default**; Flutter apps write `android.builtInKotlin=false` + `android.newDsl=false` in gradle.properties (flutter/flutter#183910).
- The module must apply `kotlin-android` whenever built-in Kotlin is NOT active. Correct guard (same pattern as flutter_timezone):
`def builtInKotlin = agpMajor >= 9 && project.findProperty('android.builtInKotlin')?.toString() != 'false'`
Do NOT "simplify" this to `== 'true'`: an absent flag means built-in Kotlin is ON (AGP default), and applying KGP then throws.
- The module never applies `kotlin-android`, not even behind a guard (built-in Kotlin migration, #743). When built-in Kotlin is NOT active, the Flutter Gradle Plugin applies KGP to plugins whose build file does not mention it. It decides that by regex over the build file text, so any `apply plugin: 'kotlin-android'` line, guarded or not, counts as "applies KGP": Flutter then skips its own apply and lists the plugin in its KGP warning (flutter/flutter#189770).
Configure the compiler only through the top-level `kotlin { compilerOptions { ... } }` block (works with built-in Kotlin and with KGP 2.0+).
- The pubspec floor is Flutter 3.47.0, not the guide's 3.44: on every 3.44.x the FGP auto-apply ignores `android.builtInKotlin`, so with `android.builtInKotlin=true` it applies KGP to this module and AGP 9 fails the build ("The 'org.jetbrains.kotlin.android' plugin is no longer required for Kotlin support since AGP 9.0"). 3.47.0 is the first release that skips the auto-apply when built-in Kotlin is on. Apps on 3.44.x keep resolving 0.10.9.
- `workmanager_android`'s build.gradle has no Flutter embedding dependency — the module can be built standalone (no Flutter SDK) to repro build issues. In real Flutter builds the FGP injects `io.flutter:flutter_embedding_debug`; `download.flutter.io` has a TLS cert mismatch (artifact only resolvable from the local Gradle cache), so standalone repros use `compileOnly` on the local engine `flutter.jar` + `androidx.core:core-ktx`, wired via an init script.
- When building the plugin through the example app, the FGP relocates the plugin's build dir: unit test results land in `example/build/workmanager_android/`, **not** `workmanager_android/android/build/`. `./gradlew :workmanager_android:testDebugUnitTest` currently runs 50 tests.

Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri May 30 01:37:19 JST 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version '8.11.0' apply false
id "org.jetbrains.kotlin.android" version "2.1.0" apply false
id "com.android.application" version '8.11.1' apply false
id "org.jetbrains.kotlin.android" version "2.3.20" apply false
}

include ":app"
37 changes: 8 additions & 29 deletions workmanager_android/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,6 @@ rootProject.allprojects {

apply plugin: 'com.android.library'

// AGP 9+ ships built-in Kotlin support and enables it by default; older
// versions need the Kotlin Gradle Plugin (KGP) applied explicitly. Flutter
// apps set `android.builtInKotlin=false` in gradle.properties
// (flutter/flutter#183910) to keep the legacy KGP path working for
// unmigrated plugins, so this module must apply KGP itself unless built-in
// Kotlin is active. See #710 and #722.
def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int
def builtInKotlin = agpMajor >= 9 &&
project.findProperty('android.builtInKotlin')?.toString() != 'false'
if (!builtInKotlin) {
apply plugin: 'kotlin-android'
}

android {
// Conditional for compatibility with AGP <4.2.
if (project.android.hasProperty("namespace")) {
Expand Down Expand Up @@ -59,24 +46,16 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

if (agpMajor < 9) {
kotlinOptions {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions.jvmTarget = "1.8"
}
}
}
}

// AGP 9: `kotlinOptions` inside `android {}` was removed. Configure the Kotlin
// compiler via the `kotlin` extension (provided by built-in Kotlin, or by KGP
// 2.0+ on the legacy path). Kept in sync with compileOptions above.
if (agpMajor >= 9) {
kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
}
// Built-in Kotlin: this module does not apply the Kotlin Gradle Plugin (KGP).
// AGP 9 compiles Kotlin itself; when built-in Kotlin is off (AGP < 9, or
// `android.builtInKotlin=false`), the Flutter Gradle Plugin (Flutter 3.44+)
// applies KGP to plugins that do not. See #743.
// Kept in sync with compileOptions above.
kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
}
}

Expand Down
4 changes: 2 additions & 2 deletions workmanager_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ repository: https://github.com/fluttercommunity/flutter_workmanager
issue_tracker: https://github.com/fluttercommunity/flutter_workmanager/issues

environment:
sdk: '>=3.5.0 <4.0.0'
flutter: ">=3.38.0"
sdk: '>=3.13.0 <4.0.0'
flutter: ">=3.47.0"

dependencies:
flutter:
Expand Down
Loading