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

26

100

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

Tucana answered 14/7, 2017 at 12:39 Comment(9)
change your dependency compile "com.android.support:cardview-v7:25.3.1 android" compile "com.android.support:recyclerview-v7:25.3.1 android"Preternatural
Click on Link . Install themKnox
Starting from version 26 of support libraries, you should add to your buildscript dependencies maven { url https://maven.google.com }, read hereFlareup
thanks all it's worked with me fine and i post the solution under questionTucana
@ahmedkhattab Could you please highlight your solution? What did you add to resolve the issue after upgrading to support library 26?Dozier
see my answer in: Setting up Gradle for api 26 (Android)Malemute
For Android Studio 2.3.3 you must add in your MODULE-LEVEL build.gradle file the following: repositories { maven { url 'maven.google.com'; } }. It is not enough the similar addition in the project-level build.gradle. See my answer to a similar question:https://mcmap.net/q/212562/-setting-up-gradle-for-api-26-androidMalemute
@Flareup man it doesn't work inside buildscript brackets. It has to be inside allprojects { repositories { maven { url "maven.google.com" } } } . Tested by me. I'm using Android Studio 2.3.3Petronella
@GianGomen Usually it should be in both places. By default when you create a new project the url "maven.google.com"; (now google()) is added in buildscript and allprojectsFlareup
B
218

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"
        }
    }
}
Bloodline answered 27/7, 2017 at 5:54 Comment(6)
Why this is not included in the default templates? It's my first time into android studio how am I supposed to know this? I guess now i know how, but it tooked me a lot of timeIngenue
Also, it doesn't work. I add this to my repositories, and I still get "Error:Failed to resolve: com.android.support:appcompat-v7:26.1.0". Have I mentioned lately that I despise gradle?Turin
@String and is it a good reason to downvote the answer? Check if you are adding in the buildscript block or the repository outside.Bloodline
My apologies, and mea culpa - I did have it in the buildscript block. Many thanks for pointing me in the direction of what I couldn't see. And I apologize for the downvote; my frustration was peaking after hours of fighting with this (and other things gradle), but that's not your fault.Turin
this bug still exist although I added google() in android studio 3.0Sectarianism
You should have mentioned Project level gradle file.Errecart
C
26

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'
    }
    
Custommade answered 16/8, 2017 at 6:2 Comment(0)
A
17

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

Ailing answered 13/1, 2018 at 20:10 Comment(1)
this was life saver, Thank youBryson
D
12

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

 maven {
    url "https://maven.google.com"
 }
Dragrope answered 4/10, 2017 at 6:21 Comment(0)
G
10

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.

Graciagracie answered 23/8, 2017 at 11:14 Comment(0)
S
6

in may case I found OneSignal changed their dependencies

so I changed it from

compile 'com.onesignal:OneSignal:[3.5.8, 3.99.99]'

to

compile 'com.onesignal:OneSignal:[3.5.8, 3.5.8]'

then it works, please check any unspecific dependency.

Standoff answered 14/8, 2017 at 13:28 Comment(0)
B
4

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()
    }
}
Blithe answered 16/8, 2017 at 17:43 Comment(0)
K
3

Google's new Maven repo is required for the latest support library that is compatible with Android 8.0. Just update your Google's Maven repository like below:

To add them to your build, add maven.google.com to the Maven repositories in your module-level build.gradle file:

repositories {
    maven {
        url 'https://maven.google.com'
        // Alternative URL is 'https://dl.google.com/dl/android/maven2/'
    }
}

Alternative you can update build.gradle file like this:

    repositories {
        jcenter()
        google()
    }

Then add the desired library to your dependencies block. For example, the cardview library looks like this:

dependencies {
    compile 'com.android.support:cardview-v7:26.1.0'
}
Kendra answered 24/9, 2017 at 7:48 Comment(0)
A
3

in sdk 28 u can use

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

and remove cardView library

Aromatize answered 28/12, 2018 at 14:41 Comment(0)
C
2

Update your Android Support Repository from sdk manager.

Cordage answered 14/7, 2017 at 12:44 Comment(0)
H
2

There is another way to add google repository

  1. Add gradle-4.1-rc-1-all in gradle-wrapper.properties.

    distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip
    
  2. Then add google() in the top-level build.gradle

    allprojects {
      repositories {
        google()
        jcenter()
      }
    }
    
Hackworth answered 25/8, 2017 at 5:42 Comment(0)
S
2

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.

Scoundrel answered 19/9, 2017 at 13:34 Comment(0)
A
2

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

Assurgent answered 4/1, 2018 at 19:1 Comment(0)
P
1

try to compile

 compile 'com.android.support:cardview-v7:25.3.1'
Pill answered 14/7, 2017 at 12:41 Comment(0)
H
1

Clean your gradle from terminal

./gradlew clean

then use this code in your build.gradle section

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

Make sure, your included library version is available. For your checking, you can use this link

Hardtack answered 19/9, 2017 at 7:50 Comment(0)
K
1

I had this issue when creating a new project in Android Studio using Kotlin. The way that finally helped me:

allprojects {
    repositories {
        maven {
            url "https://maven.google.com"
        }
        google()
        jcenter()
    }
}
Kovacs answered 12/8, 2019 at 10:5 Comment(0)
B
1

Ionic 4, opened /platforms/android/platform.properties, changed the version of the listed library throwing the error (in my case, com.android.support:support-v4:27.+) to:

com.android.support:support-v4:28.+
Busywork answered 5/2, 2020 at 21:55 Comment(0)
H
0

Use compile 'com.android.support:cardview-v7:25.4.0'
If you want version 26 you should use compile 'com.android.support:cardview-v7:26.0.0-beta2', because it is beta for now

Hoseahoseia answered 14/7, 2017 at 13:1 Comment(0)
D
0
android {
     compileSdkVersion 26
     buildToolsVersion '26.0.2'
     useLibrary 'org.apache.http.legacy'
 defaultConfig {
    applicationId "com.test"
    minSdkVersion 15
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}

this is working for me

Decommission answered 30/11, 2017 at 10:5 Comment(0)
U
0
compile 'com.android.support:cardview-v7:+' 

This should pull the most recent version, and allow it to compile.

Unravel answered 26/1, 2018 at 1:51 Comment(2)
you shouldn't use plus signs in android gradle files because it makes the build non-deterministic.Lowtension
Good to know! I appreciate your feedback and correction.Unravel
P
0

try this,

goto Android->sdk make sure you have all depenencies required . if not , download them . then goto File-->Settigs-->Build,Execution,Depoyment-->Gradle

choose use default gradle wapper (recommended)

and untick Offline work

gradle build finishes successfully for once you can change the settings

Pacify answered 2/3, 2018 at 0:8 Comment(0)
M
0

May be this problem is due to facebook library. Replace

compile 'com.facebook.android:facebook-android-sdk:[4,5)'

by

compile 'com.facebook.android:facebook-android-sdk:4.26.0'
Minnieminnnie answered 29/3, 2018 at 10:53 Comment(0)
P
0

@Aryan is correct Failed to resolve: com.android.support:appcompat-v7:27.+ (Dependency Error)

A picture worth thousand words

enter image description here

Protecting answered 4/7, 2018 at 15:36 Comment(0)
T
0

For me I just had to clean my project.

Build -> Clean Project

Another time I had to:

File -> Sync Project with Gradle Files.

Telephotography answered 27/8, 2018 at 20:14 Comment(0)
B
0

2 Steps to fix this.. 1, connect to internet. 2, Click on clean project. this will fix it :)

Backhand answered 9/9, 2018 at 13:32 Comment(0)
A
0

When you sync this dependency to the android studio:

 implementation 'com.android.support:cardview-v7:26.0.1-alpha1'

Then, Sync the Gradle with Project Files. It will say, (Suppose if you are working on new ones like androidx) obviously, it will show error on the dependency.

For that you can go to the File menu and click on the invalidate/restart the code. It will resolve itself and the application will restart without any error.

Archangel answered 14/5, 2020 at 17:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.