解析失败:com.android.support:design-v7:27.1.1

Failed to resolve: com.android.support:design-v7:27.1.1

我正在使用 Android Studio 3.1.3。 Gradle 构建同步失败。我使用了以下方法,但没有用。如果有解决办法请告诉我

  1. maven { url "https://maven.google.com" }

  2. 使重启和缓存无效

  3. multiDexEnabled true

  4. 添加 mavenLocal()mavenCentral()

    这是模块级别 build.gradle 文件:

    android {
            compileSdkVersion 27
            defaultConfig {
                applicationId "com.developers.a_g.designapp"
                minSdkVersion 15
                targetSdkVersion 27
                buildToolsVersion '27.1.1'
                versionCode 1
                versionName "1.0"
                multiDexEnabled true
                testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            }
            buildTypes {
                release {
                    minifyEnabled false
                    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                }
            }
        }
    
    dependencies {
        implementation fileTree( dir: 'libs',include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:27.1.1'
        implementation 'com.android.support.constraint:constraint-layout:1.1.2'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
        implementation 'com.android.support:cardview-v7:27.1.1'
        implementation 'com.android.support:design-v7:27.1.1'
        implementation 'com.rengwuxian.materialedittext:library:2.1.4'
        implementation 'com.szagurskii:patternedtextwatcher:0.5.0'
        implementation 'com.github.d-max:spots-dialog:0.7@aar'
        implementation 'com.squareup.retrofit2:retrofit:2.3.0'
        implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    }
    
    
     android {
            compileSdkVersion 27
            defaultConfig {
                applicationId "com.developers.a_g.designapp"
                minSdkVersion 15
                targetSdkVersion 27
                buildToolsVersion '27.1.1'
                versionCode 1
                versionName "1.0"
                multiDexEnabled true
                testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            }
            buildTypes {
                release {
                    minifyEnabled false
                    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                }
            }
        }
    
    dependencies {
        implementation fileTree( dir: 'libs',include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:27.1.1'
        implementation 'com.android.support.constraint:constraint-layout:1.1.2'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
        implementation 'com.android.support:cardview-v7:27.1.1'
        implementation 'com.android.support:design-v7:27.1.1'
        implementation 'com.rengwuxian.materialedittext:library:2.1.4'
        implementation 'com.szagurskii:patternedtextwatcher:0.5.0'
        implementation 'com.github.d-max:spots-dialog:0.7@aar'
        implementation 'com.squareup.retrofit2:retrofit:2.3.0'
        implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    }
    

这是项目级别build.gradle文件:

    buildscript {

        repositories {

            jcenter()
            google()


            maven {
                url "https://maven.google.com"
            }
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.3'
        }
    }

    allprojects {
        repositories {
            google()
            jcenter()
        }
    }

    task clean(type: Delete) {
        delete rootProject.buildDir
    }

您应该将 google() 存储库添加到您的依赖项

allprojects {
    repositories {
       google()
       jcenter() 
    }
}

不要

 implementation 'com.android.support:design-v7:27.1.1'
 buildToolsVersion '27.1.1'

implementation 'com.android.support:design:27.1.1'
buildToolsVersion '27.0.3'

请确定,您在下方添加了

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

        }
    }

然后Clean-Rebuild-Build.

首先确保您使用的是:

targetSdkVersion 27
compileSdkVersion 27
buildToolsVersion '27.0.3'

而你的 gradle 就像:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        //..
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'

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

allprojects {
    repositories {
        google()
        //..
    }
}

并像下面这样更新设计实现:

implementation 'com.android.support:design:27.1.1'

你得到这个错误是因为 com.android.support:design-v7 不存在它在没有 -v7 的情况下存在,你也可以随时检查支持库 in this link 以确保你使用的是正确的库.

在所有项目部分添加 maven URL 并同步 gradle 或尝试一个一个地删除外部库并同步 gradle 希望它有帮助

allprojects { repositories { google() jcenter()maven :"http://www.google.com" } }

这是正确的形式
实施 'com.android.support:design:27.1.1'

升级到 Android Studio 3.3 破坏了我所有的项目。

这是我今天 运行 遇到的问题之一。在浪费太多时间寻找解决方案之后,这里是工作 gradle。当我解决这个问题时,我已经忘记了我实际上在做什么。我真的很想知道为什么 Google 总是在他们的 Android Studio 中发送损坏的 gradle 文件。似乎 Google 工程师甚至自己都不知道如何编写正确的 gradle,也没有人 QA Android Studio 在其最终版本发布之前。

模块级别gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27

    defaultConfig {
        applicationId "com.journaldev.okhttp"
        minSdkVersion 25
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:design:27.1.1'
    testImplementation 'junit:junit:4.12'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
}

以及项目级别gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'

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

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

task clean(type: Delete) {
    delete rootProject.buildDir
}