我最近完成了我的应用程序的制作,并尝试按照此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'
我预计存在一些与文件或依赖项相关的问题。希望大佬能帮帮忙
从 build.gradle.kts 中删除它:
buildscript{
repositories{
google()
mavenCentral()
}
}
allprojects{
repositories{
google()
mavenCentral()
}
}
然后打开你的settings.gradle并用这个
更新
dependencyResolutionManagement
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
}
}