【问题标题】:Problem with adding repositories in build.gradle(project)在 build.gradle(project) 中添加存储库的问题
【发布时间】:2022-05-09 16:22:30
【问题描述】:
// 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 以获得完整的见解。

【问题讨论】:

  • 添加错误截图

标签: android android-studio-arctic-fox


【解决方案1】:

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

dependencyResolutionManagement {
     repositoriesMode.set(RepositoriesMode.PREFER_PROJECT)
     repositories {
         google()
         mavenCentral()
     }
}
rootProject.name = "Chat App"
include ':app'

【讨论】:

    【解决方案2】:

    我有同样的问题并解决了。转到 settings.gradle 文件 -> 更改以下代码: 从此:

    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    

    到这里:

    repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
    

    并在存储库块中添加这一行:maven { url 'https://jitpack.io' }

    【讨论】:

      【解决方案3】:
      dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
       repositories {
           google()
           mavenCentral()
       }
      

      } rootProject.name = "聊天应用"

      包括':app'

      【讨论】:

        猜你喜欢
        • 2014-01-01
        • 2023-03-26
        • 2011-06-29
        • 2019-04-30
        • 2016-01-25
        • 2021-07-11
        • 2015-04-26
        • 2022-08-03
        • 1970-01-01
        相关资源
        最近更新 更多