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.
* 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.
# 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 -versionCommon 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
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.
// 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=warnfirst 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.propertiesso they exist before evaluation. - Avoid order-dependent
extreads in Groovy DSL.