简体   繁体   English

在 build.gradle(project) 中添加存储库时出现问题

[英]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”

  • Try: Run with --info or --debug option to get more log output. Run with --scan to get full insights.尝试:使用 --info 或 --debug 选项运行以获取更多日志 output。使用 --scan 运行以获取完整的见解。

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.

相关问题 为android build.gradle文件添加额外的maven存储库不起作用 - Adding additional maven repositories for android build.gradle file is not working 我的构建配置为在项目存储库上设置存储库,build.gradle 构建文件添加了存储库“Google” - My build is configured to settings repositories over project repositories, repository ‘Google’ was added by build.gradle build file 构建被配置为更喜欢设置存储库而不是项目存储库,但是构建文件“build.gradle”添加了存储库“maven” - Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'build.gradle' 如何在模块的build.gradle中使用存储库,而不是在顶级(Project)的build.gradle中? - How can I use repositories in my module's build.gradle not in Top-level(Project's) build.gradle? 如何在 build.gradle 中包含多个存储库? - How to include multiple Repositories in build.gradle? 在build.gradle上添加存储库的位置和原因 - Where and why add repositories on build.gradle Build.Gradle 错误 - 评估项目“:app”时出现问题 - Build.Gradle Error - A problem occurred evaluating project ':app' Build.gradle:评估项目“:app”时出现问题 - Build.gradle: A problem occurred evaluating project ':app' 在 build.gradle 的第 24 行中评估项目“:app”时出现问题 - A problem occurred evaluating project ':app' in line 24 of build.gradle 在build.gradle中添加依赖项 - Adding dependency to build.gradle
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM