Gradle 未找到方法:'compile' 可能的原因:项目

Gradle method not found:'compile' possible causes : The Project

dependencies {
        classpath 'com.android.tools.build:gradle:3.5.2'


        compile 'com.android.support:appcompat-v7:24.1.1'
        compile 'com.android.support:design:24.1.1'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

我正在尝试将编译方法添加到 build.gradle 但我遇到了这个问题 我有 android studio 3.5.2

和 5.4.1 gradle

您可以将 compile 替换为 implementation:

implementation 'com.android.support:appcompat-v7:24.1.1'
implementation 'com.android.support:design:24.1.1'

但是您将依赖项放入 build.gradle 模块项目中。将它们放在 build.gradle 模块 app.