Vikas singh
Vikas singh

Reputation: 3879

Android studio 3.2.1 ArtifactResolveException: Could not resolve all artifacts for configuration ':classpath'

After I update Android Studio to 3.2.1 and gradle version in my project I am getting following build error.

I have already checked lots of questions related this question but no luck.

Project dependency Build.gradle

buildscript {

    repositories {
        google()
        mavenCentral()
        maven { url 'https://maven.google.com' }
        gradlePluginPortal()
        jcenter()
    }
    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()
        maven { url "https://jitpack.io" }
        jcenter ()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Error

org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'DemoAppppp'.
    at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:94)

Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all artifacts for configuration ':classpath'.
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.rethrowFailure(DefaultConfiguration.java:944)

Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve com.android.tools.build:gradle:3.2.1.
Required by:
    project :
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.resolveModule(RepositoryChainComponentMetaDataResolver.java:103)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.resolve(RepositoryChainComponentMetaDataResolver.java:63)

Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve com.android.tools.build:gradle:3.2.1.
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingModuleComponentRepository$ErrorHandlingModuleComponentRepositoryAccess.resolveComponentMetaData(ErrorHandlingModuleComponentRepository.java:139)

Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
    at org.gradle.internal.resource.ResourceExceptions.failure(ResourceExceptions.java:74)
    at org.gradle.internal.resource.ResourceExceptions.getFailed(ResourceExceptions.java:57)

Caused by: org.gradle.internal.resource.transport.http.HttpRequestException: Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
    at org.gradle.internal.resource.transport.http.HttpClientHelper.performRequest(HttpClientHelper.java:96)

Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:80 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect 
Caused by: java.net.ConnectException: Connection refused: connect 

Update

I just followed @CoolMind answer it solve the gradle issue, but there is another issue comes which is This

And I followed those answers which is given in this question but not solve my problem

Upvotes: 114

Views: 492693

Answers (28)

amirreza arampour
amirreza arampour

Reputation: 77

In my case i upgraded AGP version and got fixed

My error was related to "view-binding" version

If you are using tools upgrade it , Or migrate to AGP

Hope works

Upvotes: -1

Stack Ultra
Stack Ultra

Reputation: 85

In my case, I have noticed there are Test Dependencies. Upon removing these dependencies, it started working/downloading again.

these are under dependencies on build.gradle scripts

i.e.

//    testImplementation(libs.junit)

//    androidTestImplementation(libs.androidx.junit)

//    androidTestImplementation(libs.androidx.espresso.core)

Upvotes: 2

Aamir Khan
Aamir Khan

Reputation: 53

In my case i have miss typed the name of the group from "android" to "ambroid". Just check the spelling also resolved the problem.

android-gms-playservice-maps = {group = "com.google.android.gms", name="play-services-maps", version.ref = "maps"}

Upvotes: -1

Vishudh Sasidharan
Vishudh Sasidharan

Reputation: 383

In my case I had conflicting credentials for the same maven repository under different gradle files. It worked once the conflicts were resolved.

Upvotes: 0

Kaito Kitaya
Kaito Kitaya

Reputation: 61

If you are running into this problem and the above answers have not being solved yet you should check your invalid dependencies.

In my case, All of the above answers didn't solve it. I dug into the details in this error and found that there were some messages that had retrofit2 in them. So I temporarily removed retrofit2 dependencies in my module level's build.gradle.kt

build.gradle.kt

// I commented out two dependencies.
//    implementation(libs.retrofit)
//    implementation(libs.converter.gson)

After that, my project worked.

Upvotes: 0

Luis Pascual
Luis Pascual

Reputation: 255

In my case to make it work I removed the .gradle and .idea folders and then make an invalidate & restart. I hope I can help someone!

Upvotes: 0

sifr_dot_in
sifr_dot_in

Reputation: 3593

i faced this issue after adding

implementation("com.squareup.okhttp3:okhttp:3.1.0")

i removed it and issue resolved.

moral of the story:
remove older implementations if (another resource already has newer classes)
also check internet connection.

Upvotes: -1

Danson Official
Danson Official

Reputation: 99

Mostly, there is always a dependency that you might have added that doesn't exit, so you have to find and delete it. This worked for me.

Upvotes: 2

Surajkaran Meghwanshi
Surajkaran Meghwanshi

Reputation: 676

In my case I added maven repository in both repository section , so this issue occurs, So I removed this line from above repotories section inside buildscript for reference visit this answer https://stackoverflow.com/a/75005827/12748481

Upvotes: 0

Pawan Verma
Pawan Verma

Reputation: 1269

Try to Toggle Offline Mode, if not worked check your flipper version if it is old try to update it(worked for me). Upgrading flipper version in gradle.properties

From

FLIPPER_VERSION=0.39.0

To

FLIPPER_VERSION=0.99.0

Upvotes: 0

brando f
brando f

Reputation: 441

Deleting my .gradle file ("C:\Users<userName>.gradle") and going to the device manager and running "Cold Boot Now" fixed this problem for me

Upvotes: 1

Vikas singh
Vikas singh

Reputation: 3879

Just turn off the Toggle Offline Mode .

On the top right side of the Window .

Click on Gradle 2nd number option(just near of Setting option) click on it then you will be able to do work continuously.

As you can see the image

enter image description here

Upvotes: 136

gignu
gignu

Reputation: 2485

In my case none of the above helped. I had to upgrade my FLIPPER_VERSION in my gradle.properties file. You can find the latest FLIPPER_VERSION here: https://github.com/facebook/flipper/releases

Upvotes: 0

Jitendra Kohar
Jitendra Kohar

Reputation: 144

This error may arrises due to "android:exported="false"". please make sure when to use "android:exported="true/false"".

Upvotes: 0

wilfred
wilfred

Reputation: 189

You might have added a dependency not available in the repository

Upvotes: 16

Tarun Anchala
Tarun Anchala

Reputation: 2712

In my case, I have added a dependency which is not available in any of the cloud repositpories. On removing dependency,it started working

Upvotes: 40

Jack&#39;
Jack&#39;

Reputation: 2508

My problem was because a version was wrong in the dependencies in build.gradle (app). If you have internet, it might be because of this, so try finding other warnings that might indicate a wrong dependency.

Upvotes: 4

developer s
developer s

Reputation: 11

upgrade project to androidx change compile to implementation change v4 or v7 to androidx dependencies

Upvotes: 1

Tippu Fisal Sheriff
Tippu Fisal Sheriff

Reputation: 2846

Check the below points.

  1. Internet connectivity issue.
  2. Toggle Offline Mode.

enter image description here

Upvotes: 7

Ebin Joy
Ebin Joy

Reputation: 3199

For me, the issue was organization's Artifactory password got changed needed to update Gradle with new credentials.

Upvotes: 1

Rishav Sharma
Rishav Sharma

Reputation: 55

This problem occurs when your android studio is not getting internet connection. You fix the internet, the problem fixes by itself. To confirm the internet issue of the android studio you can attempt to login, update, connecting to firebase, etc all will fail.

Upvotes: 1

Lorensius W. L. T
Lorensius W. L. T

Reputation: 1744

I had this problem also. Tried all the suggestions, but didnt help. The problem was in offline/online mode as other stated but you have to also check the compiler settings. Make sure there is no --offline flag

Preferences -> Build, Execution, Deployment -> Compiler

( Menubar 'File' button, 'Settings' menu option, 'Build, Execution, Deployment' menu twisty, 'Compiler' submenu )

On Command-line Options: --stacktrace

not

--offline --stacktrace

Upvotes: 3

Eazy
Eazy

Reputation: 29

I also have been having the same error since when i updated my Android studio and even with a fast internet network am unable to start a new project but today I discover a solution just click o your event log and update any suggested plugin that shows up and rebuild your project, then your have your project working well and fine it worked for me trust it to work for you also .

Upvotes: -1

ROHIT CHAURASIYA
ROHIT CHAURASIYA

Reputation: 1

Just you have to turn on the Toggle button, come in the grade menu at the right side of the window... So you going to online mode.. you must have internet connection for.. build grade.. otherwise it's again show you same error or other types of error...

Upvotes: 0

TheJarvis
TheJarvis

Reputation: 21

Opening the "Gradle" side panel, and toggling the "online/offline" button to "online" worked for me as well.

Previous failed solution: I searched on Gradle's website for a manual download of version 3.6.3, but there wasn't one. That number is the same version, however, of Android Studio being used.

Upvotes: 2

MOHIYUDHEEN ZAHEEM
MOHIYUDHEEN ZAHEEM

Reputation: 11

If you have updated Gradle then most likely you will get this error because Gradle will be offline by default after updating.

Solution:

In right hand side top corner click Gradle (Gradle panel or Gradle window opens). Connect Gradle to the internet by clicking the icon at the top of Gradle panel or window.

Upvotes: 1

Emircan Peky&#252;rek
Emircan Peky&#252;rek

Reputation: 381

In The Right Side of the Android Studio, You can See Gradle option just click it and you will see a screen which is given below.

Gradle can be offline. If offline, you should do it online.

Screenshot

Upvotes: 34

CoolMind
CoolMind

Reputation: 28793

This problem appeared on OS X. After disabling web filtering application (some Google IPs were blocked) it disappeared. After syncing with gradle all files have been downloaded.

Also you may set a checkbox like in https://discuss.gradle.org/t/android-studio-could-not-get-resource-https-dl-google-com-dl-android-maven2-com-android-tools-build-gradle-3-1-0-gradle-3-1-0-pom/26734:

Settings -> Build … -> Gradle -> Android Studio -> Enable embedded maven repository.

See also Could not resolve com.android.tools.build.gradle:3.0.1.

Upvotes: 2

Related Questions