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

问题描述 投票:0回答:1

我最近完成了我的应用程序的制作,并尝试按照此developers.google

向其中添加广告

我在我的顶级 build.gradle.kts 中添加了 Google 的 Maven 存储库和 Maven 中央存储库,如下所示:

/ Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id("com.android.application") version "8.2.1" apply false
    id("org.jetbrains.kotlin.android") version "1.9.0" apply false
}

buildscript{
    repositories{
        google()
        mavenCentral()
    }
}

allprojects{
    repositories{
        google()
        mavenCentral()
    }
}

然后同步 gradle 项目,它会显示以下内容:

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

我预计存在一些与文件或依赖项相关的问题。希望大佬能帮帮忙

android kotlin android-jetpack-compose build.gradle
1个回答
0
投票

从 build.gradle.kts 中删除它:

buildscript{
    repositories{
        google()
        mavenCentral()
    }
}

allprojects{
    repositories{
        google()
        mavenCentral()
    }
}

然后打开你的settings.gradle并用这个

更新
dependencyResolutionManagement

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)

    repositories {
        google()
        mavenCentral()
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.