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.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
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" }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.