[英]Problem with adding repositories in build.gradle(project)
// 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
}
This is the error i am getting这是我得到的错误
A problem occurred evaluating root project 'LuckyMuch'.评估根项目“LuckyMuch”时出现问题。
Build was configured to prefer settings repositories over project repositories but repository 'Google' was added by build file 'build.gradle'
构建被配置为更喜欢设置存储库而不是项目存储库,但是构建文件“build.gradle”添加了存储库“Google”
Even I faced this issue, I have updated settings.gradle file with below code it worked for me即使我遇到了这个问题,我也用下面的代码更新了 settings.gradle 文件,它对我有用
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_PROJECT)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "Chat App"
include ':app'
I have the same problem and solved it.我有同样的问题并解决了它。 Go to settings.gradle file -> change below code: From this:
Go 到 settings.gradle 文件 -> 更改以下代码: 从这个:
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
to this:对此:
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
and add this line in the repository block: maven { url 'https://jitpack.io' }
并将此行添加到存储库块中:
maven { url 'https://jitpack.io' }
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
} rootProject.name = "Chat App" } rootProject.name = "聊天应用程序"
include ':app'包括':应用程序'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.