Search code examples
javaandroidandroid-studioandroid-gradle-plugincertificate

how to resolve SunCertPathBuilderException error for android studio


I'm getting the above error even after adding the certificate into JDK. I used the below commends to add a certificate in jdkthis android studio certificate option screen keytool.exe -import -alias gradle-keystore "C:\Program Files\Java\jdk1.8.0_261\jre\lib\security\cacerts" -file gradle.cer

still, I'm seeing the validate date as of 7/31/21.

and also I selected the non-trusted certificates automatically option.

My doubt is how to resolve the issue and I don't know where I did wrongly. please help me to resolve this issue.


Solution

  • I also faced similar issue earlier. Resolved by adding -trustcacerts in the keytool command. Refer below example.

    sudo keytool -import -trustcacerts -alias your-alias -keystore "/Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/Contents/Home/lib/security/cacerts" -file certificate-path/certificate.cer