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博客

目录
相关文章
|
JavaScript Java Maven
Nexus3.6安装、setting配置和jar包deploy
Nexus3.6安装、setting配置和jar包deploy
1169 0
Nexus3.6安装、setting配置和jar包deploy
|
Java Maven
Maven 3.8.1 报错 Blocked mirror for repositories
Maven 3.8.1 报错 Blocked mirror for repositories
974 0
Maven 3.8.1 报错 Blocked mirror for repositories
|
6月前
|
Java Maven 开发工具
maven导入项目出现Unable to import maven project: See logs for details
maven导入项目出现Unable to import maven project: See logs for details
56 0
maven导入项目出现Unable to import maven project: See logs for details
|
3月前
|
Java Maven
IDEA 报 Unable to import maven project: See logs for details
IDEA 报 Unable to import maven project: See logs for details
48 0
|
6月前
|
Java Maven
Cannot access aliyunmaven ( xxx ) in offline mode and the artifact
Cannot access aliyunmaven ( xxx ) in offline mode and the artifact
305 0
|
缓存 Java Maven
Idea Maven错误:was cached in the local repository, resolution will not be reattempted until the update
Idea Maven错误:was cached in the local repository, resolution will not be reattempted until the update
1875 0
|
Java Maven
Maven报错 Error running ‘ [install]‘:No valid Maven installation found.maven不能用
Maven报错 Error running ‘ [install]‘:No valid Maven installation found.maven不能用
866 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
6662 0
|
Java 编译器 Maven
maven项目build时出现 No compiler is provided in this environment.错误
maven项目build时出现 No compiler is provided in this environment.错误
maven项目build时出现 No compiler is provided in this environment.错误
|
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
102 0