/errors/gradle/could-not-find-method-implementation
Could not find method implementation() for arguments [...] on object of type DefaultDependencyHandler
- tool
- Gradle
- exit code
- 1
- versions
- Gradle 3.4+, Gradle 7 – 9
- os
- any
Could not find method implementation() for arguments [com.google.guava:guava:33.0.0-jre] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. means the dependencies { implementation '...' } block is evaluated in a build file where no implementation configuration exists. That configuration is created by a plugin (java, java-library, application, the Android or Kotlin JVM plugins). Apply the plugin in that file, or move the dependency into the module's build.gradle.
Common situations
dependencies {
implementation 'com.google.guava:guava:33.0.0-jre'
}plugins {
id 'java'
}
repositories {
mavenCentral()
}
dependencies {
implementation 'com.google.guava:guava:33.0.0-jre'
}In Android projects the error usually means the line went into the root build.gradle, which applies no Android plugin, instead of app/build.gradle:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:8.5.0' // classpath only belongs here
// implementation 'androidx.core:core-ktx:1.13.1' <- move this line to app/build.gradle
}
}Which configuration exists where
| Configuration | Created by |
|---|---|
| implementation, runtimeOnly, compileOnly, testImplementation | java, java-library, application, Android and Kotlin JVM plugins |
| api | java-library (and Android library) plugin |
| classpath | buildscript { } block, for plugins used by the build itself |
| compile, runtime, testCompile | Removed in Gradle 7; replace with implementation, runtimeOnly, testImplementation |
In the Kotlin DSL (build.gradle.kts) the same mistake produces Unresolved reference: implementation at script compilation, and the fix is the same: apply the plugin in that file.