Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error:Failed to resolve: com.android.support:support-annotations:27.0.1 - Android Studio [duplicate]

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

like image 549
ahmed khattab Avatar asked Jul 14 '17 12:07

ahmed khattab


9 Answers

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"
        }
    }
}
like image 142
Gabriele Mariotti Avatar answered Oct 16 '22 09:10

Gabriele Mariotti


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'
    }
    
like image 45
macbee Avatar answered Oct 16 '22 10:10

macbee


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

like image 35
D_Alpha Avatar answered Oct 16 '22 10:10

D_Alpha


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

 maven {
    url "https://maven.google.com"
 }
like image 28
Anukool srivastav Avatar answered Oct 16 '22 11:10

Anukool srivastav


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.

like image 26
Rahul Sharma Avatar answered Oct 16 '22 09:10

Rahul Sharma


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.

like image 43
Developer So far Avatar answered Oct 16 '22 11:10

Developer So far


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()
    }
}
like image 28
Pei Avatar answered Oct 16 '22 09:10

Pei


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'
}
like image 41
0xAliHn Avatar answered Oct 16 '22 09:10

0xAliHn


in sdk 28 u can use

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

and remove cardView library

like image 26
amir Avatar answered Oct 16 '22 10:10

amir