android - 在 build.gradle(project) 中添加存储库的问题

标签 android android-studio-arctic-fox

// 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”时出现问题。

Build was configured to prefer settings repositories over project repositories but repository 'Google' was added by build file 'build.gradle'


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

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

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

    关于android - 在 build.gradle(project) 中添加存储库的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68747059/

    相关文章:

    android - 如何在 Mac Eclipse-SDK 上从 Android AVD 切换到真实硬件?

    android-studio - 如何使用 Android Studio Arctic Fox 将 Android 库 aar 作为模块导入?

    java - Firebase UI RecyclerView - 处理映射

    java - Activity 上的两个 onclick 转换为 fragment

    java - Android WebView使设备不稳定

    更新到北极狐后,Android XML 预览不清楚

    android - 更新 Android Studio 4.1.2 到 2020.3.1 失败

    android - 无法在 Android Studio 北极狐中导入模块

    android - 无法启动 Kotlin REPL : CommandLineWrapper is ill-suited for launching apps

    java - 创建aar文件并进行检查