简体   繁体   中英

Gradle sync issue in android studio

Currently I am working on making an app on android studio. I was trying to add the location awareness features to my app. Therefore, after installing the google play service in android studio, I added the new dependency rule compile 'com.google.android.gms:play-services:11.0.4' . However, after I attempted to sync the gradle project but its displaying error saying

Error:Cause: unable to find valid certification path to requested target.

At first I checked into previous question that was asked before for same kind of error and I have tried every of those solution but it is still not working.

Android Studio屏幕截图

You likely have a proxy which is intercepting (via MITM) your traffic.

  1. Locate your network's certificate: In a browser, navigate to https://www.google.com " hit F12, go to certificates/security and get the top most certificate... Export it to MyCertificate.cer (base64 encoded). This process is different for each OS and Browser. Since you're on a linux/mac something like echo -n | openssl s_client -connect google.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/MyCertificate.cer should get the certificate for you in a terminal (assuming you have your distributions net-utils package installed).

  2. In a terminal, navigate to your Jetbrains installation (whichever IDE it is doesn't matter). Inside of the base folder navigate to the folder "jre64" or "jre32" or "jre" -> "lib" -> "security"

  3. Copy over MyCertificate.cer into the security folder. ( mv /tmp/MyCertificate.cer )

  4. Type keytool -keystore cacerts -importcert -alias MyCertificate -file MyCertificate.cer

  5. Use the default password of changeit .

  6. When prompted to trust the certificate type yes . Hit enter.

  7. Restart the IDE in question and it should now function normally. Repeat this process for all java (including jdk) installations and jetbrains tools just to be safe. The relative path is the same regardless: jre -> lib -> security

Are you behind a (corporate) firewall? If yes and if possible, try syncing Gradle again using another internet connection (eg at your home). Else, Milk's answer might be more helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM