Reputation: 1789
I have been getting unable to resolve dependencies error after updating the gradle to 5.1.1. I have tried all the possible solutions in this thread and this one as well. But couldn't fix my problem.
This is my error log :
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:design:28.0.0.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test:runner:1.0.2.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test.espresso:espresso-core:3.0.2.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:design:28.0.0.
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:design:28.0.0.
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:design:28.0.0.
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0.
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.3.
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:design:28.0.0.
And this is app level build.gradle
file
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.project.FirstApplication"
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'
implementation 'com.android.support:design:28.0.0'
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'
}
This is project's build.gradle
buildscript {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Regards
Upvotes: 4
Views: 2744
Reputation: 1789
For me the reason was I am working in a restricted area. So there was blocking of files being downloaded. And some how the gradle was not able to download all the dependencies. I just ran everything in open internet connectivity and it all works like a charm.
So I followed this thread to allow the packages to be downloaded in the restricted environment. Still if it didn't resolve your issue if you are working in a restricted environment contact your network guy.
Upvotes: 1
Reputation: 1299
You need classpath 'com.android.tools.build:gradle:3.3.0'
, according to this for gradle 5.1.1
.
I don't agree with tips from Deepak with putting google()
last. Historically I need it first due to other problems.
Also, your implementation 'com.android.support:appcompat-v7:28.0.0'
is redundant due to already having implementation 'com.android.support:design:28.0.0'
.
According to this you can remove
maven {
url "https://maven.google.com"
}
as well.
Upvotes: 1
Reputation: 2234
In you project level Gradle change google() position like my example.
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.1'
classpath 'io.fabric.tools:gradle:1.25.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Upvotes: 1