【已解决】ERROR: Unable to resolve dependency for ':app@debug/compileClasspath'..或者Cause: unable to find

当我们给项目添加新的依赖时,有时会提示我们:
ERROR: Unable to resolve dependency for ‘:app@debug/compileClasspath’: Could not resolve …
或者:
Cause: unable to find valid certification path to requested target
我们的代码并没有错。只是Gradle没把我们的依赖下下来而已,我们只需更改依赖仓库即可,将build.gradle(project)文件下面

buildscript {
    repositories {
    ...
    }
    }

和


allprojects {
    repositories {
 ...
    }
}

省略号里的内容替换为:

	    google()
        mavenCentral()
        mavenLocal()
        jcenter()
        maven { url 'https://jitpack.io' }

这是我尝试过很多次的,基本上都好用,不行就多试两次。

发布了47 篇原创文章 · 获赞 15 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_41525021/article/details/103487987