Gradle DSL method not found: 'implementation ()'

I had this error

Error:(45, 0) Gradle DSL method not found: 'implementation()' Possible causes:<ul><li>The project 'LaTaxi2' may be using a version of the Android Gradle plug-in that does not contain the method (eg 'testCompile' was added in 1.1.0). <a href="fixGradleElements">Upgrade plugin to version 2.3.3 and sync project</a></li><li>The project 'LaTaxi2' may be using a version of Gradle that does not contain the method. <a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin. <a href="apply.gradle.plugin">Apply Gradle plugin</a></li> 

build.gradle content

 // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { maven { url 'https://maven.google.com' } // google() jcenter() maven { url 'https://maven.fabric.io/public' } } dependencies { /* CHANGE to classpath 'com.android.tools.build:gradle:2.3.3' for STABLE BUILD TOOL VERSION*/ // classpath 'com.android.tools.build:gradle:3.0.0-alpha7' classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.google.gms:google-services:3.1.0' // We recommend changing it to the latest version from our changelog: // https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin classpath 'io.fabric.tools:gradle:1+' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { maven { url 'https://maven.google.com' } // google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } 

build .gradle module application

 apply plugin: 'com.android.application' apply plugin: 'io.fabric' repositories { maven { url 'https://maven.google.com' } // google() maven { url 'https://maven.fabric.io/public' } } android { compileSdkVersion 25 buildToolsVersion '26.0.0' defaultConfig { applicationId "in.techware.lataxi" minSdkVersion 17 targetSdkVersion 25 versionCode 5 versionName "1.0.4" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) /* Remove This to remove Crashlytics and Fabric */ compile('com.crashlytics.sdk.android:crashlytics: 2.6.7@aar ') { transitive = true; } /* compile('com.digits.sdk.android:digits: 2.0.6@aar ') { transitive = true; }*/ implementation 'com.android.support:appcompat-v7:25.4.0' implementation 'com.android.support:design:25.4.0' implementation 'com.android.support:recyclerview-v7:25.4.0' implementation 'com.squareup.okhttp3:okhttp:3.8.1' implementation 'com.android.support:cardview-v7:25.4.0' implementation 'com.github.bumptech.glide:glide:3.8.0' implementation 'com.google.android.gms:play-services-maps:11.0.2' implementation 'com.google.android.gms:play-services-location:11.0.2' implementation 'com.google.android.gms:play-services-places:11.0.2' implementation 'com.google.firebase:firebase-auth:11.0.2' implementation 'com.google.firebase:firebase-messaging:11.0.2' implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta1' implementation 'com.google.code.gson:gson:2.8.0' testCompile 'junit:junit:4.12' } apply plugin: 'com.google.gms.google-services' 
+20
source share
6 answers

To use DSL implementation() , you must use:

  • Updated gradle plugin for Android 3.0.0
  • gradle version 3.4 or later

Then in build.gradle you should 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 gradle-wrapper.properties

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

More info here .

+24
source

or if you do not want to upgrade to the latest version of Gradle, return to using the DSL method compile() instead of implementation()

+25
source

I had such a simple reason why this did not work, so I have to post my answer so that no one else goes through this.

Do not put repositories and dependencies in a file called build.gradle(Projet: YourProjectName) ! There is a comment in this file:

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

Good job to someone who puts this note there. Instead, put your repositories and dependencies in a module file with build.gradle(Module: app) called build.gradle(Module: app) .

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

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

This should allow you to synchronize and recognize the implementation .

+4
source

You are using a Turkish workspace, a change below solves the problem

 testImplementation -> testİmplementation, androidTestImplementation -> androidTestİmplementation androidTestImplementation -> androidTestİmplementation 
+3
source

implementation() replaced the compile() configuration, which will be DEPRECATED by the end of 2018.

To fix errors and use them, you need to upgrade to Android Gradle Plugin 3.0.0 (or higher). As a result of this update, you also need to upgrade Gradle to Gradle 4.1 (or higher). You also need to use Build Tools 26.0.2 (or higher), that is, update your buildToolsVersion in your build.gradle or just completely remove it from there (since, starting from 3.0.0, the minimum required version is used by default), you also You must update Android Studio 3 (or higher) to use these advanced versions.

You can read about the Android 3.0 plugin changelog, improved compilation time, and much more here: https://developer.android.com/studio/releases/gradle-plugin#3-0-0

So how do you update Android Gradle Plugin and Gradle?

OPTION 1: Manually

In your build.gradle find your path to the Gradle class and upgrade to Gradle 3.0. You should also add the google () maven repository:

 buildscript { repositories { jcenter() google() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' } } 

In gradle-wrapper.properties find your distribution Url and upgrade it to:

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

OPTION 2: through the project properties (but note that manual configuration will override it)

Go to File → Project Structure → Project

enter image description here

Lastly, you can also choose whether to replace compile () with implementation () or api (). By default, I would suggest using only the implementation (). You can read more about the differences here: https://developer.android.com/studio/build/dependencies

+1
source

In my case, it was just a typo. It was an additional “/” after one of the rows

+1
source

Source: https://habr.com/ru/post/1271147/


All Articles