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

Zulqurnain Jutt picture Zulqurnain Jutt · Jul 7, 2018 · Viewed 110.8k times · Source

Newly installed Android studio 3.1.3 is giving strange dependencies error when making a new project and compiling for very first time.

A similar question that didn't help resolve the problem.

Event Logs:

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


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.2.
Open File
Show Details


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


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.2.
Open File
Show Details


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


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.2.
Open File
Show Details


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


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.2.
Open File
Show Details


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


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.2.
Open File
Show Details

ScreenShot:

TestProject

this problem happened to me several times and forcing https or http didn't resolve it either

Answer

Shahbaz Hashmi picture Shahbaz Hashmi · Jan 31, 2019

You might be importing Application instead of Module. Well you can change it in module's gradle also.

Change

apply plugin: 'com.android.application'

to

apply plugin: 'com.android.library'

You also need to remove applicationId from the gradle.