Skip to content

/errors/gradle/could-not-find-method-implementation

Could not find method implementation() for arguments [...] on object of type DefaultDependencyHandler

The commands on this page have not been executed by our verification runner yet.updated
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

build.gradle (wrong: no plugin applied)
dependencies {
    implementation 'com.google.guava:guava:33.0.0-jre'
}
build.gradle (fixed)
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:

build.gradle (root, wrong place)
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

ConfigurationCreated by
implementation, runtimeOnly, compileOnly, testImplementationjava, java-library, application, Android and Kotlin JVM plugins
apijava-library (and Android library) plugin
classpathbuildscript { } block, for plugins used by the build itself
compile, runtime, testCompileRemoved 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.

Sources