Reputation: 8298
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
Upvotes: 98
Views: 233954
Reputation: 11
If your IDE persistently gives proxy error or Unable to find valid certification path to requested target, this steps may be solve your problem,
If you have previously made manual Proxy settings, even though we have selected no proxy, you may still be able to see this section in gradle.properties.
So you may follow this steps: 1-) Open gradle.properties in your project and delete this items.
Try again.May be this solution help.
Upvotes: 0
Reputation: 3142
I had this problem when makeing a new Android Wear OS project, and for me the problem solved just when I switched off my company's VPN for remote work and diconnected from the company network.
Upvotes: 3
Reputation: 5711
In my case below things identified
Causes - Take update from remote OR Checkout new branch
Resolution - The same issue has been resolved by disconnecting the VPN connection.
After Sync - Connect VPN again do your work as usual.
Upvotes: -2
Reputation: 3048
Since this is caused by a misconfiguration of the network you are operating on just setup your smartphone to share its internet connection using USB tethering and use it to download the missing packages.
Upvotes: 0
Reputation: 160
Check proxy application like fiddler in your system, If its running close that application and restart your android studio
Upvotes: 0
Reputation: 2869
"Unable to find valid certification path to requested target"
If you are getting this message, you probably are behind a Proxy on your company, which probably is signing all request certificates with your company root CA certificate, this certificate is trusted only inside your company, so Android Studio cannot validate any certificate signed with your company certificate as valid, so, you need to tell Android Studio to trust your company certificate, you do that by adding your company certificate to Android Studio truststore.
(I'm doing this on macOS, but should be similar on Linux or Windows)
On the popup window, to save the root certificate as a file, make sure to select the top level of the certificates chain (the root cert) and drag the certificate image to a folder/directory on your disk drive. It should be saved as a file as, for example: my-root-ca-cert.cer, or my-root-ca-cert.pem
On Android Studio open Preferences -> Tools -> Server Certificates
,
on the box Accepted certificates
click the plus icon (+
), search the certificate you saved previously and click Apply
and OK
In Android Studio open File -> Project Structure -> SDK Location -> JDK Location
Copy the path of JDK Location, and open the Terminal, and change your directory to that path, for example, execute:
cd /Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home/
(don't forget to scape the whitespace, "\ ")
Now, to import the certificate to the truststore, execute:
./bin/keytool -importcert -file /path/to/your/certificate/my-root-ca-cert.cer -keystore ./jre/lib/security/cacerts -storepass changeit -noprompt
File -> Invalidate Caches / Restart
Done, you should be able to build your project now.
Upvotes: 79
Reputation: 1075
My company has us using FortiClient VPN, which caused this error to occur.
Try disconnecting from your VPN if applicable, and try again.
Upvotes: 1
Reputation: 1064
I changed(updated) my gradle version and it worked Form
classpath 'com.android.tools.build:gradle:3.1.4'
To
classpath 'com.android.tools.build:gradle:3.3.0'
Upvotes: 0
Reputation: 3021
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.
Upvotes: 21
Reputation: 49
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.
Upvotes: -1
Reputation: 15116
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):
Upvotes: 100
Reputation: 1919
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:+'
Upvotes: 14
Reputation: 49
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.
Upvotes: 0
Reputation: 5821
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.
Upvotes: 4
Reputation: 334
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:
Upvotes: 17
Reputation: 759
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
Upvotes: 0
Reputation: 162
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
Upvotes: 0
Reputation: 33792
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.
Upvotes: 20
Reputation: 141
jcenter() equals to https://bintray.com/bintray/jcenter
You need import jcenter's cerficate into your java keystore.
Steps:
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.
Upvotes: 14
Reputation: 2520
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.
Upvotes: 0
Reputation: 91
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.
Upvotes: 1
Reputation: 1226
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"}
}
Upvotes: 25
Reputation: 9
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.
Upvotes: 0
Reputation: 126
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
Upvotes: 0
Reputation: 405
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.
Upvotes: 4