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

前端 未结 22 1075
无人及你
无人及你 2020-11-29 05:47

I got the following Error in android Studio 2.2.3 when I sync gradle.

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

相关标签:
22条回答
  • 2020-11-29 06:08

    "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)

    • First, you need to save your company root CA certificate as a file: you can ask this certificate to your IT department, or download it yourself, here is how. Open your browser and open this url, for example, https://jcenter.bintray.com/ or https://search.maven.org/, click on the lock icon and then click on Show certificate

    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

    • Second, let's add this certificate to the accepted Server Certificates of Android Studio:

    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

    • Third, you need to add the certificate to the Android Studio JDK truststore (Gradle use this JDK to build the project, so it's important):

    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
    
    • Finally, restart Android Studio, or better click File -> Invalidate Caches / Restart

    Done, you should be able to build your project now.

    0 讨论(0)
  • 2020-11-29 06:09

    I just encountered the similar problem and found a series of steps did help me. Of course few of them is to Change the network to a stronger,better one.or if you have only one network then try Reconnecting to the network and then simply INVALIDATE/RESTART your android studio. If it still shows the error you need to add the "maven" in repositories and point it out to the link as shown below: maven { url "http://jcenter.bintray.com"}

    Finally,Go to *File *Settings *Build,Execution and deployment *Gradle *Android Studio --------And check Enable maven repository option.

    After that simply clean and rebuild your APP and you will be good to go.

    0 讨论(0)
  • 2020-11-29 06:09

    You are using older version of libraries.

    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.android.support:design:25.2.0'
    compile 'com.android.support:palette-v7:25.2.0'
    compile 'com.google.firebase:firebase-messaging:10.2.0'
    
    0 讨论(0)
  • 2020-11-29 06:11

    I faced the same issue, but fixed it by adding

    maven { url "http://jcenter.bintray.com"}
    

    in the project Level Gradle File

    buildscript {
    repositories {
        jcenter()
        maven { url "http://jcenter.bintray.com"}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.google.gms:google-services:3.0.0'
    }
    }
    allprojects {
    repositories {
        mavenCentral()
        jcenter{ url "http://jcenter.bintray.com/" }
        maven { url "https://jitpack.io" }
    }
    }
    task clean(type: Delete) {
    delete rootProject.buildDir
    }
    
    0 讨论(0)
  • 2020-11-29 06:12

    I missed this problem after update studio and gradle ,in the log file tips me some maven store has certificate problem.

    I tried restart statudio as somebody suggestion but dose work; and somebody said we should set the jre environment ,but I doesn't know how to set it on Mac . So I tried restart Mac. and start studio I found this tips.enter image description here

    so the problem is floating on the surface: solution: first step: restart computer ,there are too many problem after android studio update . second step:use the old gradle tool OR download the *pom and jar ,put in correct folder.

    0 讨论(0)
  • 2020-11-29 06:12

    The error is is because of your network restriction that does not allow to sync the project from "http://jcenter.bintray.com", No need play with the IDE (Android Studio).

    0 讨论(0)
提交回复
热议问题