57

While I am importing gradle project in eclipse, it is giving me this error.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'test'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve de.richsource.gradle.plugins:gwt-gradle-plugin:0.3.
     Required by:
         :test:unspecified
      > Could not GET 'https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/de/richsource/gradle/plugins/gwt-gradle-plugin/0.3/gwt-gradle-plugin-0.3.pom'.
         > peer not authenticated

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

I am using internet via proxy connection. If that is the issue, where to specify the proxy settings inside eclipse. In General-->Network connections, proxy settings are already there

Please help.

MrTambourineMan
  • 1,025
  • 1
  • 11
  • 19

17 Answers17

74

NOTE: Please ensure the server is trustworthy before you follow these steps.

If you get any other error like this:

 Could not GET 'https://some_server.com/some/path/some.pom'.
     > peer not authenticated

Then you need to import a certificate :

keytool -import -alias <the short name of the server> -file <cert_file_name_you_exported.cer> -keystore cacerts -storepass changeit

It will prompt you to import the certificate, type yes and press enter.

Then restart your eclipse and try building the project.

dev2d
  • 4,245
  • 3
  • 31
  • 54
  • 1
    Done that. Its still giving the same error. Imported the certificates :( – MrTambourineMan Apr 05 '14 at 23:35
  • yes. build path is ok. There were two certificates to import right? – MrTambourineMan Apr 05 '14 at 23:38
  • see, if your buildpath is having referance to JRE you have to import cert to JRE/lib/security/cacerts – dev2d Apr 05 '14 at 23:39
  • also i think only one cert file you exported needed to be imported in cacerts – dev2d Apr 05 '14 at 23:40
  • 1
    yes added it to cacerts. Build path is having reference to JRE. Still same issue – MrTambourineMan Apr 05 '14 at 23:52
  • can you please check if this can help u http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Signing-Configurations – dev2d Apr 05 '14 at 23:59
  • see in all what you need to identify is, what keystore is your eclipse referring at the time of import! if it is gradle specific keystore, you need to import the cert in that keystore. because this is just a communication error between your system and GIT server. – dev2d Apr 06 '14 at 00:09
  • Same problem but this is not working for me. check this link where logs and more details regarding the problem is mentioned : https://groups.google.com/forum/#!topic/adt-dev/C3qWxrS1xrY – userv Nov 21 '14 at 06:06
  • Thank you so much. It was so complex to figure out this thing especially when gradle was giving weird error. – MFIhsan Sep 22 '15 at 01:21
  • Thank you! Thought I should change "changeit" password to something more secure. :) – Alexander Prokofyev Oct 20 '15 at 15:06
  • @VD' Hats off mate, fixed my problem! Thanks a lot! – Nabdreas Dec 11 '15 at 14:55
  • it can be anything, if server host is represented as www.google.com, you can provide alias as google, it does not matter as soon as certificate is valid but if you want to list all imported/trusted certs, you can quickly understand that the cert entry with alias "google" represents google.com's cert – dev2d Dec 28 '15 at 23:14
  • Ok thanks. Tried the said solution and build still fails in my case. Using Ionic and trying to build from the CLI. – Cozzbie Dec 29 '15 at 02:32
  • 4
    On OSX. Had to `sudo keytool ...`. – aliteralmind Jan 15 '16 at 16:28
  • Going through the steps I realized I had CharlesProxy on, disabling it fixed the issue. – Scott Jungwirth May 25 '16 at 19:51
23

ANSWER#2:Providing the correct fix after two Negative markings

Make this changes to the top-level build.gradle file.

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        //jcenter()
        jcenter {
            url "http://jcenter.bintray.com/"  <=THIS IS THE LINE THAT MAKES THE DIFFERENCE
        }
    }
}

allprojects {
    repositories {
        //jcenter()
        jcenter {
            url "http://jcenter.bintray.com/" <=THIS IS THE LINE THAT MAKES THE DIFFERENCE
        }
    }
}

ANSWER#1 (Although this is not accepted would like to keep this)

If you see "peer not authenticated errors , it does not necessarily mean that the application does not hold a valid certificate. It also could mean that connections are being reset by the firewall, load balancer, or web servers. Try (re)starting the application with the Administator privilege.

On Windows:

  • Ensure you have administrator privileges.
  • Right Click application icon -> Select "Run as Administrator"

On Linux:

  • Ensure you have root access.
  • type sudo "app execution script name"
Devendra Vaja
  • 3,836
  • 2
  • 19
  • 14
  • 1
    How does running as admin/sudo on a machine give you elevated privileges on a remote web-server or load balancer? – RaGe Feb 11 '16 at 13:24
  • It does not give privileges on the remote server. You should read the HTTPS authentication process where the certificate comes into the picture. The access to certification storage location may be accessible only using admin rights and thus the remote server could not validate the client. I hope it is clear now. – Devendra Vaja Feb 11 '16 at 16:14
  • I had the same issue. After importing the certificate from https://jcenter.bintray.com/ all .pom files could be downloaded. However I got the "peer not authenticated" error again as soon as the script started downloading the .jar files. But that was fixed after I had edited the build.gradle file as described above. – abudaan Apr 02 '16 at 12:59
  • This answer got me going! Thanks. But I would like to know, instead of editing the build.gradle for each of my projects, where does the default gradle information reside for gradle() ? Thanks – subjectivist Apr 25 '16 at 16:58
  • 1
    See http://stackoverflow.com/questions/37284472/how-do-i-change-the-default-jcenter-value-in-android-studio . Hopefully it gets an answer. – subjectivist May 17 '16 at 19:15
  • I placed vbscript at the following SO question to fix this issue in new projects: http://stackoverflow.com/questions/37284472/how-do-i-change-the-default-jcenter-value-in-android-studio/38023635#38023635 – subjectivist Jun 25 '16 at 00:01
  • Seems like http is not allowed in JCenter anymore. I get a 403: Forbidden error – MarcFasel Aug 30 '20 at 04:08
14

Change your repositories to the following in the build.gradle

repositories {
    maven  {
        url "http://repo1.maven.org/maven2"
    }
}
Shivakumar ss
  • 653
  • 7
  • 19
6

After importing the certificate as suggested in the above answer, edit your gradle.properties file and insert the following lines (having in mind your proxy settings):

HTTPS:

systemProp.https.proxyHost=www.somehost.org
systemProp.https.proxyPort=8080

HTTP:

systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080
xYan
  • 587
  • 7
  • 17
  • The fact that they're getting 'Peer not authenticated' error means that they are already able to reach the repo server, either directly, or they already configured the proxy settings. – RaGe Feb 11 '16 at 13:23
  • 1
    This worked for me, I was getting the peer not auth error and noticed I had the http proxy set but not the https one set, setting the https proxy to be the same as the http one resolved the issue. – Donal Rafferty Apr 25 '16 at 08:57
5

Upgrading from java7 to java8 did the trick for me.

tenser
  • 93
  • 1
  • 6
2

I had a strange case where I had to change the order of jcenter and maven to get rid of the error

Not working

allprojects {
repositories {
    jcenter()
    maven {
        url "https://maven.google.com"
    }
    maven { url "https://jitpack.io" }

    }
}

Working

allprojects {
repositories {
    maven {
        url "https://maven.google.com"
    }
    jcenter()
    maven { url "https://jitpack.io" }

    }
}
Marian Klühspies
  • 15,824
  • 16
  • 93
  • 136
1

I try to modify the repositories and import the cer to java, but both failed, then I upgrade my jdk version from 1.8.0_66 to 1.8.0_74, gradle build success.

Honsen
  • 307
  • 3
  • 9
1

I found that this was failing because of transient network issues with my Artifactory server. Other fixes didn't work for me, but simply retrying the build worked.

entpnerd
  • 10,049
  • 8
  • 47
  • 68
1

I using Java 11 cause this issue, problem resolved with change to Java 8, maybe you can check your java version.

Liang Lu
  • 89
  • 1
  • 3
0

I'm using android studio 1.51 with Linux (Ubuntu 14.04 LTS) and got the same error message:

Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not resolve com.github.PhilJay:MPAndroidChart:v2.1.6.
     Required by:
         dbtraining-dbtrainingandroidapp-517de26197d8:app:unspecified
      > Could not resolve com.github.PhilJay:MPAndroidChart:v2.1.6.
         > Could not get resource 'https://jitpack.io/com/github/PhilJay/MPAndroidChart/v2.1.6/MPAndroidChart-v2.1.6.pom'.
            > Could not GET 'https://jitpack.io/com/github/PhilJay/MPAndroidChart/v2.1.6/MPAndroidChart-v2.1.6.pom'.
               > peer not authenticated

I tried to move maven { url "https://jitpack.io" }, set it to http instead of https, activated the "accept non-trusted certificates automatically", added the ssl certificate manually ... but still no luck.

The solution was to switch from OpenJDK 7 to Oracle JDK 8:

  1. Downloaded the files for the JDK from Oracle, I took the tarball
    (jdk-8u101-linux-x64.tar.gz) - http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
  2. Extract the files. The folder name is jdk1.8.0_101
  3. Now switch to the directory /opt/ (nautilus hotkey: CTRL+L) and create a new folder "Oracle_Java". Maybe this requires root access, so open nautilus from the terimal with sudo nautilus
  4. Copy the folder jdk1.8.0_101 to /opt/Oracle_Java Follow the instructions from https://wiki.ubuntuusers.de/Java/Installation/Oracle_Java/Java_8/#Java-8-JDK: Do not forget to replace the version placeholder in the path with your version
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/javaws" 1
sudo update-alternatives --install "/usr/bin/jar" "jar" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/jar" 1 

sudo update-alternatives --set "java" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/java"
sudo update-alternatives --set "javac" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/javac"
sudo update-alternatives --set "javaws" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/javaws"
sudo update-alternatives --set "jar" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/jar"
  1. You can check in the terminal with the command java -version if your installation was successful.
  2. Now to back to android studio and open the project structure window by pressing the hotkey CTRL+SHIFT+ALT+S and go to SDK Location. Here you can set the path to JDK, for example /opt/Oracle_Java/jdk1.8.0_101

Change JDK version/path in android studio

That's it! :)

Stefan Brendle
  • 1,545
  • 6
  • 20
  • 39
0

I had this error and it was happening because of a VPN proxy issue. I disabled my VPN client and everything worked fine after. I used this command (on a Mac):

sudo /opt/cisco/anyconnect/bin/acwebsecagent -disablesvc -websecurity

Brod
  • 1,377
  • 12
  • 14
0

Upgrading to the latest version of gradle fixed this for me.

  1. update distributionUrl in gradle-wrapper.properties to use the latest version.
  2. update gradleVersion in build.gradle to match that version.
Calahad
  • 1,408
  • 14
  • 22
0

An old one, but since I just had this issue with an install of Eclipse 4.11...

There is apparently an issue with JDK11 which could cause this (https://github.com/spring-projects/sts4/issues/208#issuecomment-469661129). When I reverted back to my existing install of JDK8, I no longer saw the error.

peater
  • 1,233
  • 15
  • 20
0

Removing .gradle directory fixed this for me. If u r getting this due to a caching issue this will help.

Dulmina
  • 423
  • 3
  • 15
0

As suggested in some answers here, I installed Java 8 and error was gone. Seems like bug is related to Java 11.

I used jEnv to manage java versions.

brew install jenv
brew install --cask adoptopenjdk8
jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
jenv global 1.8

Selected answer didn't help, I just couldn't download said certificate using Safari...

Hlib Barylskyi
  • 865
  • 1
  • 7
  • 11
0

I recently had this same issue on Gitlab pipeline that uses gradle to build .jar.

Failing build configuration:

 gradle-build:
  image: gradle:5.2.1-jdk11-slim
  stage: build
  script:
    - ./gradlew clean
    - ./gradlew bootJar  

It turned out that I was using outdated and not-supported gradle Docker image and after upgrading to gradle:6-jdk11-alpine, build passed

0

In my case upgrading ca-certificates package that's used by openssl fixed this error.

I could download the erring file successfully using the browser and looking at previous answers on this question made me think of old root CA's at OS level and that actually worked.

Not specific to Ubuntu but leaving following url for reference https://ubuntu.com/server/docs/security-trust-store

boostrack
  • 81
  • 1
  • 3