android - 找不到参数的方法 implementation()。错误

标签 android gradle dependencies

嗨,我的构建 gradle 出现以下错误 Could not find method implemnetation() for arguments.我试图清理 gradle cache clean 项目,但没有任何效果。我看过类似的帖子,但我找不到答案。

// 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()
    }
}

最佳答案

您的项目和应用程序模块都有 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 (应用模块文件夹内的模块级别)
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 level 的文档和 module level

关于android - 找不到参数的方法 implementation()。错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49884398/

相关文章:

android - 无法解析support-vector-Drawable

android - 错误 :Flavor 'amazon' has no flavor dimension

Android studio 3 不搜索库依赖

javascript - 是否可以在我自己的项目中使用另一个包中的 npm 依赖项?

javascript - 在另一个新 Activity 中显示附加功能

android - 单击菜单项后显示另一个 Activity

android - 多维中的不同样式的applicationId

unity3d - Unity 中的 NuGet 包

android - 横向模式的方向问题

java.lang.IllegalThreadStateException : Thread already started 异常