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