5
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.0"

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

allprojects {
    repositories {
        google()
        maven { url "https://jitpack.io" }
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

这是我得到的错误

评估根项目“LuckyMuch”时出现问题。

构建被配置为首选设置存储库而不是项目存储库,但存储库“Google”是由构建文件“build.gradle”添加的

  • 尝试:使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。
4

1 回答 1

5

即使我遇到了这个问题,我也用下面的代码更新了 settings.gradle 文件,它对我有用

dependencyResolutionManagement {
     repositoriesMode.set(RepositoriesMode.PREFER_PROJECT)
     repositories {
         google()
         mavenCentral()
     }
}
rootProject.name = "Chat App"
include ':app'
于 2021-08-26T10:21:34.940 回答