Gradle DSL method not found: 'implementation()'

前端 未结 9 2085
礼貌的吻别
礼貌的吻别 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:52

    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.

    0 讨论(0)
  • 2020-11-28 14:53

    In my case it was just a typo. It was an extra sign "/" after one of rows

    0 讨论(0)
  • 2020-11-28 14:58

    I ran into similar errors. when I tried to include the recyclerview dependencies from may build.gradle(Module: app) with a code like so.

    //other build.gradle(Module: App) code above
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile 'com.android.support:appcompat-v7:25.3.1'
        compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
        testCompile 'junit:junit:4.12'
        implementation 'com.android.support:recyclerview-v7:25.3.1'
    }
    
    

    So the simple way I fixed this is by changing the code to this, where I changed the implement to compile while retaining every other code and their version numbers.

    //other build.gradle(Module: App) code above
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile 'com.android.support:appcompat-v7:25.3.1'
        compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:recyclerview-v7:25.3.1'
    }
    

    I hope this helps some one having similar issues. PS: The actual error was caused by implementation 'com.android.support:recyclerview-v7:25.3.1' and changing the code to compile 'com.android.support:recyclerview-v7:25.3.1' got it fixed.

    0 讨论(0)
提交回复
热议问题