Gradle DSL method not found: 'implementation()'

As a beginner, I discovered that there's 2 build.gradle files

It's worth checking that you didn't add the line in the wrong file. I added mine in the project file whereas I should have added it in the module one.

You can see here the 2 build in the android view


To use the DSL implementation() you have to use:

  • The updated gradle plugin for Android 3.0.0
  • The gradle version 3.4 or later

Then in your build.gradle you have to use:

buildscript {
    repositories {
        ...
        // You need to add the following repository to download the
        // new plugin.
        google()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-beta1'
    }
}

In your gradle-wrapper.properties

distributionUrl=\
  https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip

More detailed info here.


or if you don't want to update to the latest Gradle, go back to using DSL method compile() instead of implementation()


I had such a simple reason for this not working that I must post my answer to prevent anybody else going through this.

Don't put repositories and dependencies in the file called build.gradle (Project: YourProjectName)! There is a comment in that file that says:

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files

Good job to whoever put that note in there. Instead, place your repositories and dependencies in the similarly named module file build.gradle (Module: app).

There should already be a dependencies function. You may need to add repositories function. In my case, it was:

repositories {
    maven { url "https://jitpack.io" }
}

This should let you sync and recognize implementation.