Gradle DSL method not found: 'implementation()'

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

提交回复
热议问题