Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Gradle build failed. Error:Cause: peer not authenticated

Tags:

android

I have already created one project and gradle sync worked successfully.

When I try to create another project it fails and gives the error message that

Gradle '<ProjectName>' project refresh failed
     Error:Cause: peer not authenticated.

I have setup SDK, gradle gave gradle VM options

-Dhttp.proxyHost=<proxy.address> -Dhttp.proxyPort=<port> -Dhttp.proxyUser=<username> -Dhttp.proxyPassword=<password>

And in HTTP proxy tab also I have given the correct options.

Can anyone help me?

like image 679
Jijo Thomas Avatar asked Nov 04 '14 12:11

Jijo Thomas


3 Answers

This was the solution that worked for me. Posting here in case it helps someone.

Gradle version was not correct in project build.gradle file.

I had

classpath 'com.android.tools.build:gradle:1.0.0'

but this needed to be

classpath 'com.android.tools.build:gradle:2.1.0'

Note:
This should be updated to the newest version of gradle tools which can be found here Android Studio also recommends the latest plugin version.

like image 93
the_new_mr Avatar answered Nov 17 '22 06:11

the_new_mr


DO NOT change your package source to http instead of https. Stop using these workarounds and fix the root cause.

Do you want to have a driveby exploit in your app? Because that's how you get a driveby exploit in your app!

The source of this problem Certificate Authority keystore. Somehow dpkg seems to try to build the Java keystore (/etc/ssl/certs/java/cacerts) before it actually installs Java, which the the tool to build the store requires. The result is an empty store:

To fix this, properly build the keystore with all trusted CA certificates.

Run this with sudo:

sudo rm /etc/ssl/certs/java/cacerts
sudo /var/lib/dpkg/info/ca-certificates-java.postinst configure

You should see a long list of added certificates (*.pem) and finally a “done”.

Re-sync the project using gradle, and all will download. Don't forget to turn off the http override if you've set it!

Source: https://justus.berlin/2015/01/connection-problems-with-ssltls-peers-in-java-on-ubuntu-server-14-12-with-fix/

like image 18
SchizoDuckie Avatar answered Nov 17 '22 08:11

SchizoDuckie


This error says that you're trying to connect using HTTPS protocol, but your client unable to validate server's certificate - usually because it is self signed.

Connect to https://jcenter.bintray.com with your browser, and check the certificate chain. The root certificate should be issued by GeoTrust Global CA. If it's not the case, your Internet Provider or your employer perform MITM to your HTTPS connections.

If you trust them, the simple workaround will be to add those self-signed certificates into JDK's cacerts keystore. Examples for how to do that: Windows; Linux/Mac.

like image 10
Alex Lipov Avatar answered Nov 17 '22 08:11

Alex Lipov