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

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 ...


Solution 1:

Starting from version 26 of support libraries make sure that the repositories section includes a maven section with the "https://maven.google.com" endpoint.

Something like;

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

Solution 2:

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

Solution 3:

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

Solution 4:

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

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

Solution 5:

I face the same problem while I have updated my SDK and Android studio version(3.0 beta). I have solved this problem going through this tutorial. In this they told us to update are build configuration file like

android {
   compileSdkVersion 26
   buildToolsVersion '26.0.0'
   defaultConfig {
   targetSdkVersion 26
  }
  ...
}

dependencies {
   compile 'com.android.support:appcompat-v7:26.0.0'
}

// REQUIRED: Google's new Maven repo is required for the latest
// support library that is compatible with Android 8.0
repositories {
   maven {
       url 'https://maven.google.com'
       // Alternative URL is 'https://dl.google.com/dl/android/maven2/'
   }
}

Hope it will help you out.