Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0

Viewed 4352

when i new a project error above occur i use android studio 3.0 gradle 4.1 thsi is error:

Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0. Open File
Show Details

Error:Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0. Open File
Show Details

Error:Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0. Open File
Show Details

Error:Unable to resolve dependency for ':app@stagingUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0. Open File
Show Details

when i click show details the fllowing is:

Could not resolve com.android.support:appcompat-v7:26.1.0. Required by: project :app

Could not resolve com.android.support:appcompat-v7:26.1.0. Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0-beta2/appcompat-v7-26.1.0.pom'. Could not HEAD 'https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom'. Connect to dl.google.com:443 [dl.google.com/74.125.237.0] failed: Connection timed out: connect Connection timed out: connect

3 Answers

After much research and headache... Go to File\Settings\Gradle. Deselect the "Offline work" box. Now you can connect and download any necessary or missing dependencies.

I tried everything like uncheck Offline gradle, distributionUrl etc.

But adding this in end of build.gradle file solved my problem -

repositories {
    flatDir {
        dirs 'libs'
    }
}
Related