Gradle "Could not find method ..." in Build Script - Fix in CI
Gradle evaluated your build script and hit a method that does not exist in the current context. Usually the plugin that defines that method (or DSL block) was never applied, or the syntax is from the wrong DSL.
What this error means
Configuration fails with Could not find method implementation() for arguments [...] (or another method), naming the script line. Nothing builds because the script could not be evaluated.
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method implementation() for arguments [com.example:lib:1.0]
on object of type org.gradle.api.internal.artifacts.dsl.dependencies...Common causes
Required plugin not applied
Methods like implementation come from the java/java-library plugin. Without it applied, the dependencies {} configuration method does not exist.
Wrong DSL syntax
Mixing Groovy DSL syntax in a .kts file (or vice versa) - e.g. implementation 'x' in Kotlin instead of implementation("x") - makes Gradle fail to find the method.
How to fix it
Apply the plugin that defines the method
Add the plugin so its configurations and methods exist.
plugins {
`java-library`
}
dependencies {
implementation("com.example:lib:1.0")
}Match the DSL syntax to the file type
- In Kotlin (
.kts), call methods with parentheses and quotes:implementation("group:name:version"). - In Groovy (
.gradle), useimplementation 'group:name:version'. - Do not copy snippets across DSLs without converting the syntax.
How to prevent it
- Apply the plugins your script depends on, and keep build-script snippets consistent with the file DSL (Kotlin vs Groovy).