31

When you upgrade from gradle 2.0 to 2.1, you may see following error.

Could not HEAD 'https://jcenter.bintray.com/de/undercouch/gradle-download-task/1.0/gradle-download-task-1.0.pom'.
         > peer not authenticated

To be fair, this error is not due to gradle. It is problem of how java handles ssl connections.

I am using following java version.

java -version
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)

You can use following answer to import security certificate your java installation.

I do not care about https downloads, http is enough for me. So see my answer.

Community
  • 1
  • 1
Atilla Ozgur
  • 14,339
  • 3
  • 49
  • 69

5 Answers5

63

Change your repository syntax to one of the following

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


repositories {
    maven  {
        url "http://repo1.maven.org/maven2"
    }
}

Current (2.1) gradle docs claims that

Warning: Be aware that the central Maven 2 repository is HTTP only 
and HTTPS is not supported. If you need a public HTTPS enabled 
central repository, you can use the JCenter public repository 
(see Section 51.6.3, “Maven JCenter repository”).

I think maven central went for https. If I use following syntax.

repositories {
    mavenCentral()
}

I get following error.

D:\tools\gradle-2.1-bin\bin\gradle.bat -q

FAILURE: Build failed with an exception.

Atilla Ozgur
  • 14,339
  • 3
  • 49
  • 69
  • Actually this blog post is interesting: https://blog.gradle.org/unable-to-download-maven-central-bintray (This is not my blog). – stephanmg Jan 10 '20 at 13:11
12

Solution 4 “Peer Not Authenticated” while adding maven "jitpack.io" in app's gradle.build.

Simple solution is install java 8 if you have lower version. We tried with Oracle java8 and it works. :)

Note : Tried a lot of solutions those are on stackoverflow.com but none of them work for me.

PrinceMidha
  • 321
  • 3
  • 5
  • I have same issue but not resolving after install java 8. any help would be appreciating – Khizar Hayat May 17 '16 at 09:04
  • I would say, one of the most typical solutions for this problems is to update the Java Version. In my case, I switched from AdoptOpenJDK 11.0.2 to 11.0.10, which solved this problem for me – AdrianRM Jan 25 '21 at 13:10
4

I've updated the gradle wrapper to version 2.4, by changing the gradle-wrapper.properties file from:

distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip

to:

distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-bin.zip

This solved it for me.

tomrozb
  • 25,773
  • 31
  • 101
  • 122
0

I had this problem with Travis and updating gradle version (I was using gradle wrapper) solved. I was using Gradle 2.7, then I put this on build.gradle:

task wrapper(type: Wrapper) {
    gradleVersion = "2.12"
}
Raphael Amoedo
  • 4,233
  • 4
  • 28
  • 37
-2

In my case , I was using VPN and this was causing the issue . I turned off the VPN and the issue was resolved . Hope this might help anyone