安卓工作室 Gradle : Error:Configuration with name 'compile' not found

标签 android gradle

我的项目刷新失败,并出现以下 gradle 脚本的错误:错误:找不到名为“compile”的配置。

//顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.2'
        classpath 'com.google.gms:google-services:3.1.0'

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

allprojects {
    repositories {
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
apply plugin: 'com.google.gms.google-services'

最佳答案

从 project/build.gradle 中删除 apply plugin: 'com.google.gms.google-services' 并将其放入您的 app/build.gradle

apply plugin: 'com.android.application'
android {

...
..
}

dependencies {

....
..

}

apply plugin: 'com.google.gms.google-services'

关于安卓工作室 Gradle : Error:Configuration with name 'compile' not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44867212/

相关文章:

java - 为 Android 制作可再发行的组件或库

android - 在 minifyEnabled true 后,使用 google for android 登录在发布的 apk 中不起作用

android - 由于 Android 上的 lint 类路径错误,Gradle 构建失败

java - 无法访问我的库实现中的类

android - Android Studio 的配置文件

android - list 合并失败 : Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported`

android - flutter 插件 : "Methods marked with @UiThread must be executed on the main thread."

git - 添加托管在 Github 上的私有(private) Maven 存储库作为 Gradle 中的依赖项

android - 我正在使用android studio 4.0并遇到错误消息无法加载包装器属性

android - 仅将外部库的 “minifyEnabled”设置为 “false”