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
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.