Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
在Android studio 升级后遇到如下问题
Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven4(http://maven.aliyun.com/nexus/content/repositories/releases)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.2/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.
如下图所式:
Gradle 7.0 版本构建项目以上就会出现这个问题
bashUsing insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(XXX)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols
根据提示的信息的描述:意思就是maven仓库的配置需要引用HTTPS的方式进行;
同时需要针对协议进行限制;
1、原因:
gradle为了安全考虑,默认禁用使用非官方的中央仓库(比如阿里云),所以如果确认信任该仓库,需要显示声明信任它。
2、解决方法:
- 方法1
在仓库前添加关键字:allowInsecureProtocol = true
- 方法2
将仓库的http换成https
解决方案
在 自己项目的build.gradle
或者 settings.gradle
文件里面加入
pluginManagement { repositories { maven { allowInsecureProtocol true # 中间不需要加 = 号 不然不行 url '你的maven地址,需要是https的' } } } dependencyResolutionManagement { repositories { maven { allowInsecureProtocol true url '你的maven地址,需要是https的' } } }