一.问题:
使用gradle 构建maven项目时报错:
Could not resolve all dependencies for configuration ‘:Examples:debugRuntimeClasspath’.
Using insecure protocols with repositories, without explicit opt-in, is unsupported.
二. 原因
项目配置中存在一些问题,尤其是与依赖解析或仓库安全协议有关。这个问题通常出现在尝试从使用了不安全协议(如HTTP而非HTTPS)的Maven仓库中拉取依赖时。从某个版本开始,Gradle默认不允许使用不安全的协议来解决依赖。
三. 解决方法
迁移到HTTPS: 检查你的build.gradle文件(或对应的Gradle配置文件),寻找所有声明的仓库地址。如果它们是用HTTP而非HTTPS,尝试将它们更改为HTTPS。例如,如果你的配置中有这样的行:
maven { url “http://repo.maven.apache.org/maven2” }
将其更改为:
maven { url “https://repo.maven.apache.org/maven2” }