Prajyod Kumar
Prajyod Kumar

Reputation: 435

Gradle build is failing [Could not resolve all dependencies for configuration ':compile'.]

I am trying for so many days to resolve this exception , followed many blogs and couldn't find solution. when I run a bundle.gradle by giving jettyRun as command enter image description here

I am getting an exception 



    **FAILURE: Build failed with an exception.

        * What went wrong:
        Could not resolve all dependencies for configuration ':compile'.
        > Could not resolve javax.servlet:servlet-api:2.5.
          Required by:
              :1-SimpleServlet:unspecified
           > Could not GET 'http://repo1.maven.org/maven2/javax/servlet/servlet-api/2.5/servlet-api-2.5.pom'.
              > Connection to http://repo1.maven.org refused
        > Could not resolve org.apache.commons:commons-io:1.3.2.
          Required by:
              :1-SimpleServlet:unspecified
           > Could not GET 'http://repo1.maven.org/maven2/org/apache/commons/commons-io/1.3.2/commons-io-1.3.2.pom'.
              > Connection to http://repo1.maven.org refused**

Upvotes: 20

Views: 187142

Answers (10)

Vy Nguyen
Vy Nguyen

Reputation: 11

Mine worked after turning on the VPN. Although the build seems to take a long time and seems to stall at 85%, the service is actually building and I'm able to load it

Upvotes: 0

Fred
Fred

Reputation: 352

For my case it was a poor connection issue so the IDE couldn't get resources online

Upvotes: -1

vignesh294
vignesh294

Reputation: 782

The root cause Connection to http://repo1.maven.org refused indicates that the build is failing as gradle is not able to fetch some dependencies from the repository.

Here is a list of causes and corresponding resolutions you might want to try:

  1. Internet connectivity issues - Have a good internet speed and connectivity
  2. Firewall (system or third party) - Ensure firewall is not blocking access to the repository
  3. Working behind a proxy - Gradle proxy configuration
  4. Firewall or some random application meddling with proxy application1 - Kill the process meddling with the proxy application
  5. The proxy application causes certificate problems2 - Import proxy application's certificate

References:

  1. Telerik forum's answer on how to fix internet connectivity issue while using Fiddler
  2. Telerik forum's answer on secure connection issue while using Fiddler

Upvotes: 1

user292049
user292049

Reputation: 1138

I used the steps below to fix it.

  1. Go to command prompt and set the java opts.

    SET JAVA_OPTS=-Dhttp.proxyHost=your_proxy_server_name -Dhttp.proxyPort=your_proxy_port -Dhttp.nonProxyHosts=127.0.0.1
    
  2. Then build your Gradle application and all the connection refused errors no longer appear.

    gradle clean build distZip

Upvotes: 0

Farrukh Najmi
Farrukh Najmi

Reputation: 5316

In my case the problem was resolved when I changed my gradle version from 4.6 to 4.7.

Upvotes: 2

george
george

Reputation: 41

This is because of slow internet connection or you haven't configure proxy settings correctly. Gradle needs to download some dependencies , if it cant access the repository it fires this error. All you have to do is check your internet connection and make sure gradle can access the maven repository.

Upvotes: 1

phoenix
phoenix

Reputation: 617

Using --refresh-dependencies switch with gradle, helped me to resolve this issue.

Upvotes: 9

Aaron Digulla
Aaron Digulla

Reputation: 328556

The real error is this:

Connection to http://repo1.maven.org refused

Gradle needs to download the dependencies listed in the error message to be able to compile the project.

You're probably behind a firewall or your Internet connection isn't working. You need to make sure Gradle can access http://repo1.maven.org.

Note: Maven Central (http://repo1.maven.org) can be accessed with a browser. If you see the message "Browsing for this directory has been disabled" that means your browser could connect to the server (the error is a special message my Maven Central, not a standard HTTP error message).

If you see this but Maven or Gradle fail, then you need to check your browser's/OS's proxy settings and configure your tool accordingly.

Related:

Upvotes: 19

Bharatesh
Bharatesh

Reputation: 9009

@Aaron Digulla said I have firewall problem.

I was having problem with GSON dependency, (hope it will solve other dependecy problems also) and this answer solved the problem. Stack Overflow Could not resolve all dependencies for configuration ':classpath'

@Kangars post : This is what i have in my gradle.build for build script and allprojects

buildscript {
repositories {
    jcenter {
        url "http://jcenter.bintray.com/"
    }
  }
}

allprojects {
repositories {
    jcenter {
        url "http://jcenter.bintray.com/"
    }
  }
}

Upvotes: 1

deveth0
deveth0

Reputation: 508

It looks like you don't have a working internet connection or haven't configured your proxy/firewall. Please check if you can access repo1.maven.org from commandline or a browser.

Upvotes: 0

Related Questions