Repository navigation
Description
Refiling #189726, which was auto-closed on 2026-08-11 for no response and locked on 2026-08-25, as the closing bot instructed. Triage asked that report for a minimal repro and whether it still occurred on 3.44.7, and never got an answer. Both answers are below: it reproduces from flutter create in two commands, and the responsible source is byte-identical on every stable release since, including current master.
Steps to reproduce
No sample repository is needed — a clean scaffold reproduces it:
flutter create cc_repro
cd cc_repro
echo "org.gradle.configuration-cache=true" >> android/gradle.properties
flutter build apk --debugExpected results
The build succeeds; the configuration cache entry is stored and reused.
Actual results
BUILD FAILED. Gradle cannot serialize the task graph, because two Flutter Gradle Plugin doLast closures capture configuration-time objects.
Capture site 1 — DependencyVersionChecker.configureMinSdkCheck (DependencyVersionChecker.kt#L149-L179). The doLast captures the AGP Variant (it) and the Project:
androidComponents?.onVariants(androidComponents.selector().all()) {
val minSdkCheckTask = project.tasks.register(taskName) {
doLast {
val minSdkVersion = getMinSdkVersion(it) // captures Variant
try {
checkMinSdkVersion(minSdkVersion, project.rootDir.path, project.logger) // captures Project
} catch (e: DependencyValidationException) {
project.extra.set(OUT_OF_SUPPORT_RANGE_PROPERTY, true) // captures Project
throw e
}
}
}Configuration cache state could not be cached: field `queue` of `java.util.WeakHashMap`
… bean found in field `bundleConfig` of `com.android.build.api.variant.impl.ApplicationVariantImpl_Decorated`
bean found in field `$it` of `com.flutter.gradle.DependencyVersionChecker$configureMinSdkCheck$1$minSdkCheckTask$1$1`
bean found in field `action` of `org.gradle.api.internal.AbstractTask$TaskActionWrapper`
bean found in field `actions` of task `:app:DebugMinSdkCheck` of type `org.gradle.api.DefaultTask`:
error writing value of type 'java.lang.ref.ReferenceQueue'
6 problems were found storing the configuration cache, 5 of which seem unique.
- Task `:app:DebugMinSdkCheck`: cannot serialize object of type 'DefaultConfigurationContainer' … not supported with the configuration cache.
- Task `:app:DebugMinSdkCheck`: cannot serialize object of type 'DefaultDependencyHandler' … not supported with the configuration cache.
- Task `:app:DebugMinSdkCheck`: cannot serialize object of type 'DefaultProject', a subtype of 'org.gradle.api.Project' … not supported with the configuration cache.
- Task `:app:DebugMinSdkCheck`: cannot serialize object of type 'PropertiesBuildService' … not supported with the configuration cache.
- Task `:app:DebugMinSdkCheck`: error writing value of type 'java.lang.ref.ReferenceQueue'
Four of those five are disallowed-type captures, independent of the ReferenceQueue reflection failure.
Capture site 2 — FlutterPlugin.addFlutterTasks (FlutterPlugin.kt#L390-L394), assembleTask.doLast { … output as ApkVariantOutput … }. Re-running with -PskipDependencyChecks=true removes the MinSdkCheck task, and the identical failure then fires from :app:assembleDebug:
… bean found in field `services` of `com.android.build.gradle.internal.api.ApkVariantOutputImpl_Decorated`
bean found in field `$output` of `com.flutter.gradle.FlutterPlugin$addFlutterTasks$2$1$1`
bean found in field `actions` of task `:app:assembleDebug` of type `org.gradle.api.DefaultTask`:
error writing value of type 'java.lang.ref.ReferenceQueue'
10 problems were found storing the configuration cache, 6 of which seem unique.
This site already carries // TODO(gmackall): Migrate to AGPs variant api. https://github.com/flutter/flutter/issues/166550.
So --android-skip-build-dependency-validation is not a workaround: it only removes site 1.
Additional context
Answering the triage question on #189726 — yes, it still occurs. I inspected configureMinSdkCheck on each tag; the capturing doLast is unchanged on 3.44.7, 3.44.8, 3.44.9 and master. (The build above was run on 3.44.6; the newer versions were verified by source inspection, not by re-running.)
Not JDK-25-specific. #189726 was reported on Windows 11 / JDK 25 / AGP 9.3.0 / Gradle 9.5.0. This reproduction is Linux / JDK 21.0.11 / AGP 9.0.1 / Gradle 9.1.0 — a different platform and toolchain, same two capture sites. The Gradle daemon's default --add-opens list has never included java.base/java.lang.ref on any Java version.
Suggested direction (unchanged from #189726): have the doLast closures capture only serializable values computed at configuration time — the variant name and minSdk.apiLevel as plain values, rootDir as a String — or wire them as Provider-based task inputs, instead of capturing Variant / Project / ApkVariantOutput. Related: #166550, and the same class of bug previously fixed in #139325 ("Do not use project in do last").
Workaround for users: keep org.gradle.configuration-cache=false for Flutter Android builds. Note that a GRADLE_USER_HOME/gradle.properties entry overrides the project file, so the cache must not be force-enabled machine-wide.
Flutter version
flutter doctor -v
[✓] Flutter (Channel stable, 3.44.6, on Ubuntu 24.04.4 LTS 6.15.11-061511-generic, locale C.UTF-8)
• Flutter version 3.44.6 on channel stable at /home/rob/development/sdk/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ee80f08bbf (8 weeks ago), 2026-07-08 15:02:06 -0700
• Engine revision 83675ed276
• Dart version 3.12.2
• DevTools version 2.57.0
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
• Platform android-36, build-tools 36.0.0
• Java version OpenJDK Runtime Environment (build 21.0.11+10-1-24.04.2-Ubuntu)
• All Android licenses accepted.
[✓] Linux toolchain - develop for Linux desktop
[✓] Network resources
Gradle 9.1.0, AGP 9.0.1 (both from the unmodified flutter create template).
Activity
saurabh-mirajkar commentedon Aug 31, 2026
@robertmc0 Thanks for the detailed refile. I was able to reproduce this from a clean
flutter createproject on Flutter 3.47.2/macOS with Gradle configuration cache enabled.This is related to the previously closed #189726, which was closed after the requested reproduction/version information was not provided. Since that information is now available here, keeping this report open for further investigation.
Also related to #166550.
Vectorial1024 commentedon Sep 21, 2026
Hi there, currently if we are in the page for #189726 we cannot know that this 192035 issue exists, because the original report is locked. Perhaps a repo collaborator may add a comment at the old page indicating that the issue has updates here?