Skip to content
Latchkey

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

Gradle
> 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

  1. Add the java, java-library, or Android plugin to the project.
  2. Keep the dependencies {} block in the project that has the plugin.
  3. Re-evaluate the build.
build.gradle.kts
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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →