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

2019-02-27 13:13发布

I am using Android Studio 3.1.3. Gradle build sync failed. I used following method but there is no use of it. If there is any solution please tell me

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

  2. Invalidate restart & caches

  3. multiDexEnabled true

  4. Adding mavenLocal() and mavenCentral()

    This is module level build.gradle file:

    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'
    }
    

This is project level build.gradle file:

    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
    }

6条回答
小情绪 Triste *
2楼-- · 2019-02-27 13:30

this is the correct form
implementation 'com.android.support:design:27.1.1'

查看更多
一纸荒年 Trace。
3楼-- · 2019-02-27 13:39

Don't

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

Do

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

Make sure, you added below

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

        }
    }

Then Clean-Rebuild-Build.

查看更多
SAY GOODBYE
4楼-- · 2019-02-27 13:39

Upgrade to Android Studio 3.3 destroyed all my projects.

This was one of the problems today I ran into. And after wasting too much time to find a solution, here is the working gradle. By the time I fixed this, I had forgotten what actually I was working on. I really wonder why Google always ship their Android Studio with broken gradle files. Seems like Google engineers even themselves don't know how to write proper gradle, and nobody QAs Android Studio before its final release.

Module level 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'
}

And the project level 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
}
查看更多
做自己的国王
5楼-- · 2019-02-27 13:44

First make sure that you using:

targetSdkVersion 27
compileSdkVersion 27
buildToolsVersion '27.0.3'

And your gradle be like:

// 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()
        //..
    }
}

And also update design implementation like below:

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

You get this error because com.android.support:design-v7 does not exist it exist without -v7, also you can check support libraries in this link any time to make sure you are using the correct library.

查看更多
乱世女痞
6楼-- · 2019-02-27 13:52

You should add google() repository to your dependencies

allprojects {
    repositories {
       google()
       jcenter() 
    }
}
查看更多
迷人小祖宗
7楼-- · 2019-02-27 13:54

Add the maven URL in all projects section as well and sync the gradle or try removing one by one external libraries and sync the gradle hope it helps

allprojects { repositories { google() jcenter()maven :"http://www.google.com" } }
查看更多
登录 后发表回答