Skip to content
Latchkey

Gradle "Could not get unknown property" - Fix Build Script in CI

A build script referenced a property that does not exist on the object it asked. Usually an ext/project property, a version-catalog accessor, or a Gradle property is misspelled, never defined, or read before it is set.

What this error means

Configuration fails with Could not get unknown property '<name>' for project ':<module>' (or for a task/extension). The build never reaches your tasks - it fails while evaluating the script.

gradle output
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not get unknown property 'springBootVersion' for project ':app'
  of type org.gradle.api.Project.

Diagnose it: get the real failure out of Gradle

Gradle summarises failures aggressively, and the top-level message frequently describes a downstream symptom rather than the cause. Re-run the failing task with diagnostics before changing build logic.

Terminal
# the actual stack, plus what Gradle decided about the build
./gradlew <task> --stacktrace --info

# is a stale daemon or cache involved?
./gradlew --stop
./gradlew <task> --no-daemon --no-build-cache

# what does Gradle think the environment is?
./gradlew -version

Common causes

Property never defined or misspelled

An ext property, a gradle.properties entry, or a version-catalog alias is referenced under a name that was never set, or with a typo (springBootVersion vs springbootVersion).

Property read before it is set

In Groovy DSL, reading ext.foo in a block that evaluates before ext.foo = ... resolves to nothing. Ordering and configuration timing matter.

How to fix it

Define the property before using it

Set the property in gradle.properties or an ext/extra block evaluated before the reference.

gradle.properties + build.gradle.kts
// gradle.properties
springBootVersion=3.3.2

// build.gradle.kts
dependencies {
    implementation("org.springframework.boot:spring-boot-starter:${property("springBootVersion")}")
}

Prefer a version catalog for shared versions

A typed catalog accessor fails at configuration with a clear message instead of an unknown-property error.

libs.versions.toml
// gradle/libs.versions.toml
[versions]
springBoot = "3.3.2"
[libraries]
spring-boot-starter = { module = "org.springframework.boot:spring-boot-starter", version.ref = "springBoot" }

Configuration cache and CI

  • The configuration cache rejects build logic that reads mutable state at execution time, which is why enabling it surfaces errors an existing build never showed.
  • Run with --configuration-cache-problems=warn first to see the full list rather than failing on the first one.
  • A cached configuration keyed to a different environment is worse than none. Include the JDK version in your cache key.

How to prevent it

  • Define shared versions in a version catalog (libs.versions.toml).
  • Set scalar properties in gradle.properties so they exist before evaluation.
  • Avoid order-dependent ext reads in Groovy DSL.

Frequently asked questions

What causes Gradle "Could not get unknown property"?
There are 2 common causes: property never defined or misspelled and property read before it is set. An ext property, a gradle.properties entry, or a version-catalog alias is referenced under a name that was never set, or with a typo (springBootVersion vs springbootVersion).
How do I fix Gradle "Could not get unknown property"?
There are 2 fixes depending on which cause you have: define the property before using it and prefer a version catalog for shared versions. Work through them in order, since the first is the most common.
What does Gradle "Could not get unknown property" actually mean?
Configuration fails with Could not get unknown property '<name>' for project ':<module>' (or for a task/extension).
How do I stop Gradle "Could not get unknown property" happening again?
Define shared versions in a version catalog (libs.versions.toml). The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card