Android ERROR: Failed to resolve: com.github.**** 报错

亲身体验过,好好的项目,突然运行不起来了,可能前一刻还好好的,妈的,一顿操作猛如虎,奈何就是现实项目中的一些依赖,尤其是com.github.XXX 相关的三方,就是下载不下来 ,各种找一搞一下午,突然找到一个能直接解决的办法:

可能是项目的Build.gradle 的 maven 仓库的配的位置不对,至于之前为什么可以,我也不清楚,这样:
你之前的写法:

buildscript {
    repositories {

        google()
        jcenter()
        maven { url 'https://www.jitpack.io' }
        mavenCentral()
        maven { url 'https://repo1.maven.org/maven2/' }
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.1"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

现在的写法:

buildscript {
    repositories {

        google()
        jcenter()
//        maven { url 'https://www.jitpack.io' } 把这个放到下面,立马就好了。
        mavenCentral()
        maven { url 'https://repo1.maven.org/maven2/' }
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.1"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
        mavenCentral()
        maven { url 'https://repo1.maven.org/maven2/' }
        maven { url "https://oss.jfrog.org/libs-snapshot" }
    }
}

我开始还担心这个可能不一定解决,我不断的修改其它依赖,都可以下载下来,真是厉害了。哈哈哈,这里记录一下。

你可能感兴趣的:(Android ERROR: Failed to resolve: com.github.**** 报错)