Skip to content
Latchkey

Gradle configuration cache "problems were found" with Kotlin build in CI

The Gradle configuration cache stores the configured task graph and forbids capturing live objects (the Project, a Task, script state) at execution time. A Kotlin build that references those inside a task action fails the cache with a list of "problems".

What this error means

The build fails (or warns then fails) with "Configuration cache problems found in this build" followed by entries such as "invocation of Task.project at execution time is unsupported".

Gradle
Configuration cache problems found in this build.
1 problem was found storing the configuration cache.
- Task `:app:generateBuildConfig`: invocation of 'Task.project' at execution time is unsupported.

Common causes

A task action reads project state at execution time

Custom Kotlin DSL logic calls project. or references another task directly inside doLast {}, which the configuration cache cannot serialize.

A plugin not yet compatible with the cache

An older Kotlin or third-party plugin captures disallowed state; enabling the cache in CI surfaces problems that were silent before.

How to fix it

Capture values at configuration time, not execution time

  1. Read which task and which reference the report names.
  2. Move project. reads out of doLast/doFirst into configuration, capturing plain values or providers.
  3. Re-run with the cache enabled to confirm zero problems.
build.gradle.kts
abstract class WriteVersion : DefaultTask() {
    @get:Input abstract val version: Property<String>
    @TaskAction fun run() { /* use version.get(), not project */ }
}

Upgrade or drop the incompatible plugin

Bump plugins to configuration-cache-compatible releases, or scope the cache off only where a plugin is not ready yet.

Terminal
./gradlew build --configuration-cache

How to prevent it

  • Use lazy providers and typed inputs in custom tasks instead of Project references.
  • Keep the Kotlin plugin and third-party plugins current for configuration-cache support.
  • Enable the configuration cache in CI early so problems surface before they compound.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →