可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I'm getting this error
Gradle 'project_name' project refresh failed: Unable to find valid certification path to requested target
when I create a new project on Android Studio 0.8.14 Mac OSX
Build.gradle file seems to become empty
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
} }
allprojects {
repositories {
jcenter()
} }
And I can't run the project, seems that I have to configure everything manually.
Here is the idea.log http://pastebin.com/kyhfrBp9
回答1:
It happened to me, and turned out it was because of Charles Proxy.
Charles Proxy is a HTTP debugging proxy server application
Solution (only if you have Charles Proxy installed):
- Shut down Charles Proxy;
- Restart Android Studio.
回答2:
For me the issue was android studio was not able to establish connection with
'https://jcenter.bintray.com/'
Changing this to 'http' fixed the issue for me (Though this is not recommended).
In your build.gradle file, change
repositories {
jcenter()
}
to
repositories {
maven { url "http://jcenter.bintray.com"}
}
回答3:
If you are working in a restricted workplaces you probably will encounter this problem
A combination of a few things worked for me
Basically change https to http
From https:
repositories {
jcenter()
}
To :
repositories {
maven { url "http://jcenter.bintray.com" }
}
and in gradle-wrapper.properties
..
From :
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
To :
distributionUrl=http\://services.gradle.org/distributions/gradle-3.3-all.zip
And then
- (optional) File -> Invalidate Caches / Restart`
- Give a clean build.
To verify : Check your Gradle console. It should start downloading libs from jcenter via HTTP.
回答4:
Okay, Probably I am late but I have faced this issue after upgrading to 3.0.1 from 3.0.
And this problem because I am working in restricted network.
The solution which worked for me is as follow:
Solution
Step 1: Get Certificate
jcenter()
equals to https://bintray.com/bintray/jcenter
You need import jcenter's cerficate into your java keystore.
Visit jcenter using your browser and export the certificate as .cer file. (lock icon on the left of Firefox address bar, or Chrome developer tool secuity tab. Internet Explorer and Edge do not support saving of Website certificates, though.)
Step 2: Import Certificate
In Android Studio, go to File -> Settings -> Tools -> Server Certificates
.
Under Accept certificates click on +
. Select the exported certificate.
Step 3: Refresh Keystore In Android Studio, go to File -> Invalidate Caches/Restart...
. Select Invalidate and Restart
from the message box that appears.
回答5:
Even though this question is very old, many must be facing the same issue, so I would like to state how I fixed this.
The problem is classpath 'com.android.tools.build:gradle:0.13.2'
By above line in build.gradle you are asking it to find a particular version of gradle but this version is not there in your machine. The best it to change the above line to
classpath 'com.android.tools.build:gradle:+'
回答6:
jcenter() equals to https://bintray.com/bintray/jcenter
You need import jcenter's cerficate into your java keystore.
Steps:
- Visit jcenter using your browser
and export the certificate as .crt file. (lock icon on the left of Firefox
address bar, or Chrome developer tool secuity tab)
- Download
this tool and run it.
- Select "Open an existing KeyStore" button
to open JDKPATH/jre/lib/security/cacerts, the password is "changeit"
- Use the "Import Trusted Certificate" button to import the .crt file, then save and exist
If you are behind proxy, in gradle.properties, besides setting
systemProp.http.proxyHost and systemProp.http.proxyPort
also set
systemProp.https.proxyHost and systemProp.https.proxyPort
By now it should be fine.
回答7:
I'm in an enterprise environment with a proxy/firewall/virus-scanner combination adding the company own SSL root certificate (self signed) to the trustpath of every SSL connection to investigate also into SSL connections. That was exactly the problem. If you are in the same situation this solution could help:
- Open https://jcenter.bintray.com in the browser (I prefer Firefox)
- Click on the padlock symbold to check the certificated trustpath. If the top/root certificate in the tree is a certficate signed by your company export it to your harddisk.
- To be safe export also every certificate in between
- Open the truststore of Android Studio in path JDKPATH/jre/lib/security/cacerts with the Keystore Explorer tool Keystore Exlorer with password "changeit"
- Import the exported certs into the trusstore starting with the root certificate of you company and go the step 6. In the most cases this will do the trick. If not, import the other certs as well step by step.
- Save the truststore
- Exit Android Studio with "File -> Invalidate Caches/Restart"
回答8:
Seems like a bug to me.
I've had the same problem and worked around it by manually starting gradlew.bat in my project directory.
回答9:
Try to update your Android Studio, now is version 1.0.2
回答10:
For me it was my internet, I was working on restricted network
回答11:
Add latest gradle version properly in build.gradle file and latest distributionUrl in gradle-wrapper.properties file.
[refer https://developer.android.com/studio/releases/gradle-plugin.html for the latest gradle version of android studio]
Make sure network connectivity is proper [ Network connection should not block upgrading gradle in android studio].
After gradle upgrade android studio will prompt alert to accept/decline certificate and we should accept the certificate.
回答12:
Go to The Gradle Console in bottom right and open it.Here you will be seeing some https/https calls click on the links and open them in web browser then try clean build it worked for me.
I think It is happening because studio is not able to get the response from the hit.
回答13:
I got it because I'm behind a proxy. I had set the http but not the https proxy in gradle.properties. Https was needed in this case:
systemProp.http.proxyHost=<host>
systemProp.http.proxyPort=<port>
systemProp.https.proxyHost=<host>
systemProp.https.proxyPort=<port>
Also, take a look at the Android Studio logs for where the error could be.
回答14:
I had this problem today after upgrading to Android Studio 3.2 Beta 2. I had configured my JDK for OpenJDK 10.0.1, and it threw this error after upgrading. I set the JDK back to using the enbedded JDK, and the error went away.
I have no idea why it worked fine before I upgraded to Beta 2, but all is good now. Honestly I guess there is no need for OpenJDK 10 for Android.
回答15:
If you still have the problem, try deleting the directory named '.AndroidStudio1.2' under 'C:\Users\UserName\.AndroidStudio1.2'
Of course the name differs according to which version you have
That worked for me
回答16:
It usually happen when your have included the dependency and it won't have repository reference like mavenCentral() or jcenter() etc to download it
What I usually do identify such dependency is set gradle to work offline, Android studio will automatically show a dependency which is not locally available, then look for the dependency details in their providers github page like from which repository to pick from and update your repositories and sink it. Hope it will work
回答17:
I faced similar error after upgrading to Android Studio 3.1.2
with gradle 4.4
& plugin 3.1.2
, then tried almost all of the above solutions with generating the same error again & again.
Invalidate Caches / Restart
finally have done me the favor: File
>Invalidate Caches / Restart...
>Invalidate and Restart
回答18:
Sometimes it happens due to Network issue so try ,
- change your connection and try again...
after changing to unrestricted network try [uninstalling android studio] completely and try again..
[uninstalling android studio]:How to completely uninstall Android Studio from windows(v10)?
回答19:
I had the same issue and it was caused because cyberoam was blocking my following URL
Caused by: org.gradle.api.resources.ResourceException: Unable to load Maven meta-data from https://maven.fabric.io/public/io/fabric/tools/gradle/maven-metadata.xml.
回答20:
Here is my solution for key phrases of the messages: “unable to find valid certification path” and “PKIX path building failed“.
These phrases are shown when a SSL certification file can not be found.
Open https://jcenter.bintray.com/ in your browse and export the certificate in cer format.
Put the certificate in Android Studio’s cert folder
{your-home-directory}/.AndroidStudio3.0/system/tasks/cacerts
Then all went well.
回答21:
It was too strange issue. We had struggled a lot. After reboot of working machine problem disappeared. Magic...