Failed to resolve_ com.android.xxx Add Google Maven repository and sync project

Failed to resolve_ com.android.xxx Add Google Maven repository and sync project

问题描述

运行程序出现这种错误,导致程序无法执行。

    ERROR: Failed to resolve: com.android.support:appcompat-v7:26.1.0
    Add Google Maven repository and sync project
    Show in Project Structure dialog
    Affected Modules: app

    ERROR: Failed to resolve: com.android.support:design:26.1.0
    Add Google Maven repository and sync project
    Show in Project Structure dialog
    Affected Modules: app

    ERROR: Failed to resolve: com.android.support:recyclerview-v7:22.2.0
    Add Google Maven repository and sync project
    Show in Project Structure dialog
    Affected Modules: app

    ERROR: Failed to resolve: com.android.support:support-v4:21.0.3
    Add Google Maven repository and sync project
    Show in Project Structure dialog
    Affected Modules: app


解决方法

在最外层build.gradleallprojects闭包中加上maven路径:

    allprojects {
        repositories {
            jcenter()
            maven {
                url "https://maven.google.com"
            }
        }
    }

记住是在最外层的build.gradle,不是app下的build.gradle哦。


评论区

  目录