Juan
Juan

Reputation: 21

Unable to resolve dependency android studio

It is my first time to make a new project in android studio. Then i got this type of error after i added the build tools to 27.0.3 and checked the "Enable embedded Maven Repository" in Setting. Can anyone help me how to solve this ? Thank you.

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Could not resolve com.android.support:appcompat-v7:28.0.0.">Show Details</a>    
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Could not resolve com.android.support.constraint:constraint-layout:1.1.3.">Show Details</a>
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test:runner:1.0.2.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not resolve com.android.support.test:runner:1.0.2.">Show Details</a>   
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': 

Could not resolve com.android.support.test.espresso:espresso-core:3.0.2.
    <a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not resolve com.android.support.test.espresso:espresso-core:3.0.2.">Show Details</a>   
    Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
    <a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not resolve com.android.support:appcompat-v7:28.0.0.">Show Details</a> 
    Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
    <a 
href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not resolve com.android.support.constraint:constraint-layout:1.1.3.">Show Details</a> 
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not resolve com.android.support:appcompat-v7:28.0.0.">Show Details</a>    
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not resolve com.android.support.constraint:constraint-layout:1.1.3.">Show Details</a> 
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve junit:junit:4.12.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not resolve junit:junit:4.12.">Show Details</a>   
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@release/compileClasspath&#39;: Could not resolve com.android.support:appcompat-v7:28.0.0.">Show Details</a>  
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@release/compileClasspath&#39;: Could not resolve com.android.support.constraint:constraint-layout:1.1.3.">Show Details</a>   
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@releaseUnitTest/compileClasspath&#39;: Could not resolve com.android.support:appcompat-v7:28.0.0.">Show Details</a>  
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@releaseUnitTest/compileClasspath&#39;: Could not resolve com.android.support.constraint:constraint-layout:1.1.3.">Show Details</a>   
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve junit:junit:4.12.
<a href="openFile:C:/Users/Juan/AndroidStudioProjects/HelloWorldApp/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@releaseUnitTest/compileClasspath&#39;: Could not resolve junit:junit:4.12.">Show Details</a> 

Here is my file build.gradle for (project: HelloWorldApp )

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

Here is my file build.gradle for(Module:app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.abc.helloworldapp"
        minSdkVersion 15
        targetSdkVersion 28
        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:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

Upvotes: 2

Views: 6874

Answers (3)

Ali Nawaz
Ali Nawaz

Reputation: 2500

I have remained stuck into this sort of issue a long time, finally resolved this issue after watching the issue very carefully, which is pointing that

Unable to resolve dependency for ':app@debug/compileClasspath'

You need to make a sure and double check if the class is residing there. This one thing will prove much helpful to many I guess because focusing on this point took me much closer to the solution.

Thanks

Upvotes: 1

ʍѳђઽ૯ท
ʍѳђઽ૯ท

Reputation: 16976

This is because of gradle or internet connection.

Try updating your gradle to 3.2.0 version:

classpath 'com.android.tools.build:gradle:3.2.0'

In your root of project -> Build.gradle where it has buildscript - dependencies. You can find it with the file which has classpath in the dependencies. It is called project/yourprojectname on Android Studio.

Upvotes: 0

SinaMN75
SinaMN75

Reputation: 7659

Sometimes it happens when it cannot connect to the required server, so you have to verify some things. 1. you have to verify you have network connection. 2. you have to verify if you can connect to the specific server, so try using some vpns. 3. verify that your gradle in online, to do this go to preferences on mac and for windows I think it's gonna be Settings, => Gradle.

Upvotes: 0

Related Questions