Failed to resolve: com.android.support:cardview-v7

2018-12-31 02:16发布

i try to add recyclerview to my project and get this error appear and i added it from android studio dependencies this is error appear when try to add recyclerview in android studio

this is the compiled version ...

23条回答
后来的你喜欢了谁
2楼-- · 2018-12-31 02:28

Just add this to your main all project level build.gradle file under allprojects()

 maven {
    url "https://maven.google.com"
 }
查看更多
初与友歌
3楼-- · 2018-12-31 02:35

Simply change the build-version from compile 'com.android.support:appcompat-v7:26.0.0'

to

compile 'com.android.support:appcompat-v7:26.0.0-alpha1'

This will solve your problem.

查看更多
人气声优
4楼-- · 2018-12-31 02:36

Add this to the project level build.gradle file and it should work fine.

allprojects {
    repositories {
        google() // this is to be added if there's something already.
        jcenter()
    }
}
查看更多
公子世无双
5楼-- · 2018-12-31 02:38

If you are using Android Studio 3.0 or above make sure your project build.gradle should have content similar to-

buildscript {                 
    repositories {
        google()  // add google() before jcenter()
        jcenter()
    }
    dependencies {            
        classpath 'com.android.tools.build:gradle:3.0.1'

    }
}

allprojects {
    repositories {
        google()  // add google() before jcenter()
        jcenter()
    }
}

And for below Android Studio 3.0 and starting from support libraries 26.+ your project build.gradle must look like this-

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

Note- position really matters add google() before jcenter()

check these links below for more details-

1- Building Android Apps

2- Add Build Dependencies

3- Configure Your Build

查看更多
有味是清欢
6楼-- · 2018-12-31 02:38

If the other solutions here do not work, make sure you are not in 'offline' mode. If enabled, android will not download the required files and you will get this error.

enter image description here

查看更多
听够珍惜
7楼-- · 2018-12-31 02:41

This is how I have it working.

  1. Add maven { url "https://maven.google.com" } as @Gabriele_Mariotti suggests above.

    allprojects {
        repositories {
            jcenter()
            maven {
                url "https://maven.google.com"
            }
        }
    }
    
  2. Then on the build.gradle file inside the App folder add

    compileSdkVersion 26
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "com.xxx.yyy"
        minSdkVersion 16
        targetSdkVersion 26
    }
    
  3. Then on the dependencies use

    dependencies {
        compile 'com.android.support:appcompat-v7:26.0.1'
        compile 'com.android.support:design:26.0.1'
        compile 'com.google.android.gms:play-services-maps:11.0.4'
        compile 'com.google.android.gms:play-services-location:11.0.4'
        compile 'com.mcxiaoke.volley:library-aar:1.0.0'
        compile 'com.android.support:cardview-v7:26.0.1'
    }
    
查看更多
登录 后发表回答