Repository navigation
Description
Steps to reproduce
- Enable Gradle's configuration cache for a Flutter Android app, e.g. in
android/gradle.properties(or anyGRADLE_USER_HOME/gradle.properties):org.gradle.configuration-cache=true - Run
flutter build apk --debug(or./gradlew :app:assembleDebugdirectly).
Expected results
The build succeeds; the configuration cache entry is stored and reused.
Actual results
The build fails at configuration-cache store time. The Flutter Gradle plugin has (at least) two task actions that capture configuration-time objects (Variant, Project, ApkVariantOutput) into doLast closures, so Gradle must serialize those object graphs, which is not supported.
Capture site 1 — DependencyVersionChecker.configureMinSdkCheck (packages/flutter_tools/gradle/src/main/kotlin/DependencyVersionChecker.kt, doLast captures the AGP Variant and the Project):
Configuration cache state could not be cached: field `queue` of `java.util.WeakHashMap` bean found in field `values` of `org.jetbrains.kotlin.gradle.utils.StoredPropertyStorage` bean found in field `storage` of `org.gradle.internal.extensibility.DefaultExtraPropertiesExtension` bean found in field `extraProperties` of `com.android.build.gradle.internal.services.ProjectServices` bean found in field `projectServices` of `com.android.build.gradle.internal.services.VariantServicesImpl` bean found in field `variantServices` of `com.android.build.api.variant.impl.BundleConfigImpl` 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 actions of task `:app:DebugMinSdkCheck` of type `org.gradle.api.DefaultTask`: error writing value of type 'java.lang.ref.ReferenceQueue'
> Unable to make field private volatile java.lang.ref.Reference java.lang.ref.ReferenceQueue.head accessible: module java.base does not "opens java.lang.ref" to unnamed module
Gradle additionally reports 6 configuration cache problems for :app:DebugMinSdkCheck, including captures of disallowed types Project, ConfigurationContainer, DependencyHandler, and KGP's PropertiesBuildService.
Capture site 2 — FlutterPlugin.addFlutterTasks (packages/flutter_tools/gradle/src/main/kotlin/FlutterPlugin.kt, assembleTask.doLast { output as com.android.build.gradle.api.ApkVariantOutput ... }). Reproducible by re-running with -PskipDependencyChecks=true, which removes the MinSdkCheck task — the identical failure then fires from :app:assembleDebug:
Configuration cache state could not be cached: field `queue` of `java.util.WeakHashMap` bean found in field `values` of `org.jetbrains.kotlin.gradle.utils.StoredPropertyStorage` ... bean found in field `$output` of `com.flutter.gradle.FlutterPlugin$addFlutterTasks$2$1$1` bean found in field `action` of `org.gradle.api.internal.AbstractTask$TaskActionWrapper` bean found in actions of task `:app:assembleDebug` of type `org.gradle.api.DefaultTask`: error writing value of type 'java.lang.ref.ReferenceQueue'
> Unable to make field private volatile java.lang.ref.Reference java.lang.ref.ReferenceQueue.head accessible: module java.base does not "opens java.lang.ref" to unnamed module
This second site already carries // TODO(gmackall): Migrate to AGPs variant api. https://github.com/flutter/flutter/issues/166550.
Additional context
- Not JDK-25-specific. Verified by running the identical build with a JDK 21 daemon (
-Dorg.gradle.java.home=<jdk-21.0.10>): byte-for-byte the same failure. The Gradle daemon's default--add-openslist (org.gradle.internal.jvm.JpmsConfiguration) has never includedjava.base/java.lang.refon any Java version, and 4 of the 6 reported problems are JDK-independent disallowed-type captures. The same signature was reported against a different capturing plugin in mid-2024 (JetBrains CMP-4904). - Not fixable by upgrading: reproduced identically with AGP 9.0.1→9.3.0, Kotlin 2.3.20→2.4.10, Gradle 9.1.0→9.5.0.
--android-skip-build-dependency-validationis not a workaround (it only removes capture site 1; site 2 still fails).- The source on
masteris currently identical to 3.44.0 for both capture sites. - Related: Remove code that manipulates AGP tasks by discovering them via their name #166550 (migrate away from name-based AGP task manipulation), and the same class of bug was previously fixed in Do not use project in do last #139325 ("Do not use project in do last").
- Suggested direction: make the
doLastclosures capture only serializable values computed at configuration time (e.g. the variant name andminSdk.apiLevelas plain values,rootDirpath asString), or useProvider-based task inputs, instead of capturingVariant/Project/ApkVariantOutput.
Workaround for users: org.gradle.configuration-cache=false for the Flutter Android build (note a GRADLE_USER_HOME/gradle.properties entry overrides the project file, so the cache must not be force-enabled machine-wide).
Flutter version
Flutter 3.44.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 559ffa3f75 (2026-05-15)
Engine • hash fcf463a2242790d1fdcd9d044f533080f5022e18 (revision 4c525dac5e)
Tools • Dart 3.12.0 • DevTools 2.57.0
Environment: Windows 11, Gradle 9.5.0 (also 9.1.0), AGP 9.3.0 (also 9.0.1), Kotlin 2.4.10 (also 2.3.20), JDK Temurin 25.0.3 (also reproduced with JDK 21.0.10).
Activity
puneetkukreja98 commentedon Jul 21, 2026
@Avilash14 Thanks for reporting this issue.
Could you please provide a link to a minimal sample GitHub repository so we can clone it and reproduce the problem? Also, could you check if this still occurs on the latest Flutter stable channel (3.44.7)?
If the issue persists, please share your flutter doctor -v output along with the complete console error logs.
revert(android): 撤回配置缓存——Flutter Gradle 插件本身不兼容
github-actions commentedon Aug 11, 2026
Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
Thanks for your contribution.
github-actions commentedon Aug 25, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.