构建配置为首选设置存储库而非项目存储库,但构建文件“build.gradle”添加了存储库“Google”

mwecs4sa  于 2023-03-08  发布在  Go
关注(0)|答案(4)|浏览(273)

添加allprojects {}时评估根项目时出现问题。原因是:用户代码无效异常:构建配置为首选设置存储库而非项目存储库,但构建文件"build. gradle"添加了存储库"Google"
下面是build.gradle中的代码

buildscript {
repositories {
    google()
    mavenCentral()

}
dependencies {
    classpath "com.android.tools.build:gradle:7.0.0"
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
}
}

allprojects {
repositories {
    google()
    mavenCentral()
    maven { url 'https://jitpack.io' }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
kfgdxczn

kfgdxczn1#

适用于Android Studio北极狐|2020.3.1从build.gradle中删除此文件

allprojects {
repositories {
    google()
    mavenCentral()
    maven { url 'https://jitpack.io' }
}

}转到settings.gradle并添加以下行

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
    google()
    mavenCentral()
    jcenter()
    maven { url 'https://jitpack.io' }
}

}

8wtpewkr

8wtpewkr2#

对于Sping Boot gradle项目,这是您可以指定build.gradle的方式之一

buildscript {

repositories {
    mavenCentral()
maven {
            url can be given like this "https://plugins.gradle.org/"
        }
}
dependencies {
    classpath "com.android.tools.build:gradle:7.0.0"
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
}
}
aor9mmx1

aor9mmx13#

构建配置为首选设置存储库而非项目存储库,但构建文件“build.gradle”添加了存储库“Google”

unftdfkk

unftdfkk4#

转到设置.gradle并按如下所示进行更新

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
    google()
    mavenCentral()
    jcenter()
    maven { url 'https://jitpack.io' }
}

相关问题