找不到参数的方法implemnetation()。错误

时间:2018-04-17 17:43:48

标签: android gradle dependencies

您好我在构建gradle上遇到了followin错误Could not find method implemnetation() for arguments.我试图清理gradle缓存清理项目但没有任何效果。我见过similliar帖子,但我找不到答案。

// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'java-library'
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        implementation 'org.hibernate:hibernate-core:3.6.7.Final'
        api 'com.google.guava:guava:23.0'
        testImplementation 'junit:junit:4.+'
        implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.6.+@aar'

    }
}

allprojects {
    repositories {
        jcenter()
    }
}

1 个答案:

答案 0 :(得分:1)

您的项目和应用程序模块都有一个build.gradle文件。

在这里混合顶级build.gradle,应该是这样的:

项目build.gradle (项目文件夹中的顶级)

//the `java-library` plugin is unnecessary here
buildscript {
    repositories {
        mavenCentral()
        google()
    }
    dependencies {
        //the gradle plugin version is the same as Android Studio, here v3.1.1 which is currently the latest stable
        classpath 'com.android.tools.build:gradle:3.1.1'
    }
}

allprojects {
    repositories {
        mavenCentral()
        google()
    }
}

应用模块build.gradle (您应用模块' s文件夹中的模块级别)

apply plugin: 'com.android.application'

android{...}
dependencies {
    implementation 'org.hibernate:hibernate-core:3.6.7.Final'
    api 'com.google.guava:guava:23.0'
    testImplementation 'junit:junit:4.+'
    implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.6.+@aar'
}

有关这2个build.gradle文件的详细信息,请参阅top levelmodule level

的文档。