Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'build.gradle'
时间: 2023-10-31 09:31:59 浏览: 34
这个警告信息表示在 Gradle 的构建配置中,优先使用了设置仓库(settings repositories)而不是项目仓库(project repositories),但是在 build.gradle 文件中,却添加了一个名为 'maven' 的仓库。
这种情况下,Gradle 会使用 build.gradle 文件中指定的仓库 'maven',而不是使用设置仓库中的同名仓库。如果你确实需要使用设置仓库中的 'maven' 仓库,可以在 settings.gradle 文件中指定该仓库,或者在命令行中使用 `-Dorg.gradle.project.repo.maven.url=<url>` 来指定该仓库的 URL。如果不需要使用该仓库,可以在 build.gradle 文件中移除该仓库的配置。
相关问题
Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'build.gradle
感谢您提出的问题!根据您描述的情况,这个警告消息是由于在构建文件 `build.gradle` 中添加了名为 'maven' 的存储库,但构建配置设置为优先使用设置存储库而不是项目存储库。
在 Gradle 的配置中,您可以指定构建所需的存储库。默认情况下,Gradle 会首先检查构建配置文件中定义的存储库,然后才会检查项目级别的存储库。
建议您检查 `build.gradle` 文件中的存储库定义,确保这是您想要的行为。如果您希望构建使用项目级别的存储库而不是设置级别的存储库,您可以调整 Gradle 配置以避免此警告。
请记住,Gradle 的详细配置取决于项目的具体情况,我无法提供更具体的解决方案,但希望这些信息对您有帮助!如有其他问题,请随时提问。
Build was configured to prefer settings repositories over project repositories but repository 'MavenRepo' was added by build file 'app\build.gradle'
这个警告是因为在你的项目中,Gradle 配置文件 `build.gradle` 中添加了一个名为 `MavenRepo` 的仓库,但是你的 Gradle 配置中也存在一个或多个仓库,Gradle 会优先使用这些仓库而不是你在 `build.gradle` 中定义的仓库。
如果你想要使用 `MavenRepo`,可以在 `build.gradle` 文件中将其放在其他仓库的前面。或者,你也可以在 Gradle 的配置文件中删除其他仓库,以便使用 `MavenRepo`。
具体来说,你可以在 `build.gradle` 文件中添加以下内容:
```gradle
repositories {
maven { url 'MavenRepo的地址' }
// 其他仓库
}
```
这样,在 Gradle 构建时就会优先使用 `MavenRepo` 仓库。
如果你想要删除其他仓库,可以在 Gradle 配置文件中找到类似以下的内容:
```gradle
repositories {
google()
jcenter()
}
```
将其修改为:
```gradle
repositories {
maven { url 'MavenRepo的地址' }
}
```
这样就只使用了 `MavenRepo` 仓库。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)