I had this error
Error:(45, 0) Gradle DSL method not found: \'implementation()\'
Possible causes:- The project \'LaTaxi2\' may be using a
You using Turkish workspace, below change solves the problem
testImplementation -> testİmplementation,
androidTestImplementation -> androidTestİmplementation
androidTestImplementation -> androidTestİmplementation
in my case i add these line and issue resolved
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
or if you don't want to update to the latest Gradle, go back to using DSL method compile()
instead of 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.
implementation()
has replaced compile()
configuration, which will be DEPRECATED by the end of 2018.
In order to fix your errors and use it, you must update to Android Gradle Plugin 3.0.0 (or higher). As a result of this update, you also need to update Gradle to Gradle 4.1 (or higher). You also need to use Build Tools 26.0.2 (or higher), meaning to update your buildToolsVersion
in your build.gradle
, or just completely remove it from there (as, since 3.0.0, the minimum required version is used by default). You also need to update to Android Studio 3 (or higher) in order to use those advanced versions.
You can read about the changelog of android gradle plugin 3.0.0, the improved compile times, and more, here: https://developer.android.com/studio/releases/gradle-plugin#3-0-0
So how to update Android Gradle Plugin and Gradle?
OPTION 1: Manually
In your build.gradle
find your gradle classpath and update version to gradle 3.0. Also, google() maven's repository should be added:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
In gradle-wrapper.properties find your distributionUrl and update to:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
OPTION 2: Through project properties (But notice the manual configuration WILL override it)
Go to File→Project Structure→Project
One last thing, you can also choose whether to replace compile() by implementation() or by api(). By default I would suggest just to use implementation(). You can read more about the differences here: https://developer.android.com/studio/build/dependencies
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
.