Gradle "Could not find method implementation()" in CI
The implementation dependency configuration is added by the Java or Android plugin. When a build script declares implementation(...) in a project that never applied such a plugin, Gradle has no such method and fails while evaluating the script.
What this error means
Configuration fails with "Could not find method implementation() for arguments [...] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler".
> Could not find method implementation() for arguments
[com.example:widgets:1.4.0] on object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.Common causes
No plugin defines the configuration
The dependencies {} block uses implementation, but the project applied neither the java nor an Android plugin, so that configuration does not exist.
Dependencies declared in the wrong project
A root or settings script that does not apply a component plugin tries to add implementation dependencies meant for a subproject.
How to fix it
Apply the plugin that defines the configuration
- Add the
java,java-library, or Android plugin to the project. - Keep the
dependencies {}block in the project that has the plugin. - Re-evaluate the build.
plugins { id("java-library") }
dependencies { implementation("com.example:widgets:1.4.0") }Move dependencies to the right subproject
Declare component dependencies in the subproject that applies a plugin, not in a root build script that does not.
How to prevent it
- Apply a component plugin before using its dependency configurations.
- Keep
dependencies {}blocks in projects that have the right plugin. - Avoid putting component dependencies in the root project by mistake.