Android Studio 3.1.1同步成功但报HttpRequestException警告求助
Hey there, let's work through this SSL handshake warning you're seeing. Even though your project sync finishes successfully, that PKIX path building failed error means your system can't verify the SSL certificate for the jcenter repository—here are some tried-and-true fixes:
1. Check Proxy Settings
First up, proxies often mess with SSL certificate verification. Head over to Android Studio's Settings > Appearance & Behavior > System Settings > HTTP Proxy and switch to No proxy. Then click Apply and re-sync your project. If you need a proxy, make sure it's configured to properly pass SSL traffic without intercepting certificates.
2. Align Gradle Plugin & Android Studio Versions
Your error mentions trying to fetch gradle-3.1.2.pom, but you're on Android Studio 3.1.1. Version mismatches can cause unexpected issues:
- Open your project's root
build.gradlefile - Update the Gradle plugin classpath to match your AS version:
buildscript { dependencies { classpath 'com.android.tools.build:gradle:3.1.1' // Match your AS 3.1.1 version } } - Also check the Gradle wrapper version in
gradle/wrapper/gradle-wrapper.properties—make sure it's compatible with the 3.1.1 plugin (Gradle 4.4 is recommended for plugin 3.1.1).
3. Import Missing SSL Certificate to Java Truststore
If your system doesn't trust jcenter's SSL certificate, you'll need to manually add it to your Java truststore:
- Open https://jcenter.bintray.com in your browser, click the lock icon in the address bar, and export the site's SSL certificate (save it as a
.cerfile in DER format). - Locate the truststore file for your Java installation—usually at
JDK_HOME/jre/lib/security/cacertsor the embedded JRE in Android Studio (look underAndroid Studio/jre/lib/security/cacerts). - Run this keytool command to import the certificate (replace paths with your own):
The default truststore password iskeytool -import -alias jcenter-cert -keystore /path/to/cacerts -file /path/to/your/certificate.cerchangeit—enter it when prompted. - Restart Android Studio and re-sync your project.
4. Temporary Workaround: Disable SSL Verification (Not Recommended for Production)
If you need a quick fix (and understand the security risks), you can bypass SSL checks for jcenter:
- In your project's
build.gradle, replace the jcenter entry with either the HTTP version:repositories { jcenter { url "http://jcenter.bintray.com/" } } - Or, if you're using Gradle 6.0+, use the insecure protocol flag:
repositories { maven { url "https://jcenter.bintray.com/" allowInsecureProtocol = true } }
内容的提问来源于stack exchange,提问作者Sanjay Kumar

