Gradle DSL method not found: 'implementation()'

前端 未结 9 2151
礼貌的吻别
礼貌的吻别 2020-11-28 14:29

I had this error

Error:(45, 0) Gradle DSL method not found: \'implementation()\'
Possible causes:
  • The project \'LaTaxi2\' may be using a
9条回答
  •  伪装坚强ぢ
    2020-11-28 14:48

    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

提交回复
热议问题