1

I am getting this error while sync gradle project.

Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:design:26.1.0

can anyone help me?

apply plugin: 'com.android.application' android {
compileSdkVersion 26
defaultConfig {
    applicationId "com.example.phaniteja.sample1"
    minSdkVersion 15
    targetSdkVersion 26
    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'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' }
  • @VishvaDave check now –  Mar 19 '18 at 08:57
  • This issue happens because studio is not able to download support lib from Maven2 or jcenter . Make sure if offline work is disabled in settings->Build,Execution ->Gradle. – Sunil Sunny Mar 19 '18 at 08:57
  • @sunilsunny yes it is off only. the check box is not marked for offline work –  Mar 19 '18 at 09:00
  • https://stackoverflow.com/a/48092108/8089770 – Vidhi Dave Mar 19 '18 at 09:03
  • Possible duplicate of [Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0](https://stackoverflow.com/questions/46999594/unable-to-resolve-dependency-for-appdebug-compileclasspath-could-not-resolv) – Vidhi Dave Mar 19 '18 at 09:04
  • @VishvaDave i tried that link . but no use –  Mar 19 '18 at 09:05
  • @phani Can you try changing 26.1.0 to 25.1.0 for both support libraries. – Sunil Sunny Mar 19 '18 at 09:09
  • @sunilsunny yes error is coming. like if i place 25.1.0, the text is underlined with red color line. –  Mar 19 '18 at 09:12
  • @phani That's just a warning. You should be able to run though. – Sunil Sunny Mar 19 '18 at 09:13
  • @sunilsunny 'Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not download support-annotations.jar (com.android.support:support-annotations:25.4.0)' this error is coming –  Mar 19 '18 at 09:15
  • 25.4.0 ? you changed to 25.1.0 right ? and also where is support-annotations in your gradle?. Can you go to this path Android-sdk\extras\android\m2repository\com\android\support\appcompat-v7 and see which versions are available in your SDK give either one of those. – Sunil Sunny Mar 19 '18 at 09:19
  • @sunilsunny D:\sdk\extras\m2repository\com\android\support\constraint\constraint-layout. after support appcompact-v7 is not there. support folder contains constraint and in constraint, constraint-layout and constraint-layout-sovler folders were there. –  Mar 19 '18 at 09:27
  • @sunilsunny i got that folder. in that v 18.0.0 to 26.0.0-alpha1 versions are there –  Mar 19 '18 at 09:30
  • @sunilsunny i placed 26.0.0-alpha1. It si working. Thank you –  Mar 19 '18 at 09:32
  • @phani Ok . I will give it as an answer with explanation. You can accept the answer. – Sunil Sunny Mar 19 '18 at 12:24

2 Answers2

1

Unable to resolve dependency for :app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:design:26.1.0 This issue usually happens when the Android Studio is not able to download that dependency.That can be due to many reasons like this Or like in my case where the Maven2 and jcenter repositories are blocked in Company. So what can you do is like check this folder

Android-sdk\extras\android\m2repository\com\android\support\appcompat-v7

and check which all versions are available to you in the SDK, use either one of those versions ,So instead of downloading from repository studio will take that lib from SDK.

Sunil Sunny
  • 3,949
  • 4
  • 23
  • 53
0

Try to add your Google maven repo. it works for me.##

repositories {
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Gourav Samre
  • 134
  • 1
  • 7