Build was configured to prefer settings repositories over project repositories but repository

简介: Build was configured to prefer settings repositories over project repositories but repository

Build was configured to prefer settings repositories over project repositories but repository


首先上链接:stackoverflow的正解

下载了最新版的狐狸图标的AS,4.1.2版本,

新建的项目默认使用的最新版本7.0.2的gradle,

在项目的build.gradle中添加项目编译需要的依赖,

allprojects {
 
repositories {
 
google()
 
jcenter()
 
}
 
}

然后,报错,编译不过。提示也说了,构建被配置应该写到 设置存储库 setting.gradle中,而不是项目存储库 build.gradle,但是构建文件'build.gradle'添加了存储库“ Google”。

problem occurred evaluating root project 'My Application'.
> Build was configured to prefer settings repositories over project repositories but repository 'Google' was added by build file 'build.gradle'

百度没用,Google中搜到了:最新的项目编译依赖配置改到settings.gradle中了:

In settings.gradle you can add the repositories you want to add to the project

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

当然,又试了一下,把setting.gradle中的这个内容删除,添加到项目的build.gradle中,也正常编译运行:

allprojects {
 
repositories {
 
google()
 
mavenCentral()
 
jcenter() // Warning: this repository is going to shut down soon
 
}
 
}

最近有空又了解了一下,在settings.gradle中配置依赖项,是gradle 7.0以后新增的统一管理依赖的方式,上链接:

Gradle7.0】依赖统一管理的全新方式

(316条消息) Build was configured to prefer settings repositories over project repositories but repository ..._hpp_1225的博客-CSDN博客

目录
相关文章
|
Java Maven
Maven 3.8.1 报错 Blocked mirror for repositories
Maven 3.8.1 报错 Blocked mirror for repositories
698 0
Maven 3.8.1 报错 Blocked mirror for repositories
|
26天前
|
Java Maven 开发工具
maven导入项目出现Unable to import maven project: See logs for details
maven导入项目出现Unable to import maven project: See logs for details
16 0
maven导入项目出现Unable to import maven project: See logs for details
|
11月前
|
Java Linux 网络安全
Maven Setting文件介绍
Maven Setting文件介绍
1659 0
|
12月前
Plugin ‘maven-clean-plugin:3.1.0‘ not found
Plugin ‘maven-clean-plugin:3.1.0‘ not found
152 0
|
Java Maven
maven install时报错The packaging for this project did not assign a file to the build artifact
maven install时报错The packaging for this project did not assign a file to the build artifact
4880 0
|
Android开发
Migrate Project to Gradle? This project does not use the Gradle build system
Migrate Project to Gradle? This project does not use the Gradle build system
80 0
|
存储 Java Maven
Maven - Artifact upload failed. Repository with ID='XXX' does not allow updating artifacts.
Maven - Artifact upload failed. Repository with ID='XXX' does not allow updating artifacts.
118 0
|
前端开发 JavaScript Java
reuse project的maven build log(下)
reuse project的maven build log(下)
|
Java jenkins 持续交付
reuse project的maven build log(上)
reuse project的maven build log(上)
|
Java 测试技术 Maven
${project.build.directory}
${project.build.directory}
${project.build.directory}