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
distributionUrl=http://services.gradle.org/distributions/gradle-2.1-all.zip
keep the http://
Usually this error happens when you're under a company proxy. My solution on MAC was this:
Identify the Certificate is being used by your https connections
Open Key Chain Tools (cmd+space key chain)
Open the terminal and navigate to your JAVA JRE security folder:
cd /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/security
Import the certificate with the following command:
sudo keytool -import -alias somealias -file /PATH_TO_EXPORTED_CERTIFICATE/certificate.cer -keystore cacerts -storepass changeit
That is done. Open Android Studio and it will fix the gradle build.
In case this helps someone, I had the same issue and even though I set the proxy through the studio settings ( which adds the values of systemProp.http.proxyHost
and systemProp.http.proxyHost
to gradle.properties), https proxy was not set, so I added this in gradle.properties
systemProp.https.proxyHost = <your proxy host>
systemProp.https.proxyPort = <your proxy port>
and problem solved!
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.
As this occurs I using Ubuntu: When I changed version on android studio 2.0 9 preview beta 1.
How do I fix my gradle.
Simply created a new project in android studio and then went in and saw build.grandle version gradle in my case:
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta1'
}
and replace in my project.
I hope it helps others.