HarmonyOS鸿蒙Next中Gradle同步失败(unable to find valid certification path to requested target)
HarmonyOS鸿蒙Next中Gradle同步失败(unable to find valid certification path to requested target)
已经尝试过的办法
- 更改英文路径
- 将路径层数改为一层
- 清缓存重启
- 导入证书
这两个网站的证书全部都在C:\Program Files\Huawei\DevEco Studio\jbr\jre\bin里面导入了
统统失败了。。。。。。
详细报错信息如下:
FAILURE: Build failed with an exception.
-
What went wrong: A problem occurred configuring root project ‘MyApplication2’.
-
Could not resolve all artifacts for configuration ‘:classpath’.
- Could not resolve com.huawei.ohos:hap:2.0.0.6.
Required by:
project :
- Could not resolve com.huawei.ohos:hap:2.0.0.6.
- Could not get resource ‘https://mirrors.huaweicloud.com/repository/maven/com/huawei/ohos/hap/2.0.0.6/hap-2.0.0.6.pom’.
- Could not GET ‘https://mirrors.huaweicloud.com/repository/maven/com/huawei/ohos/hap/2.0.0.6/hap-2.0.0.6.pom’.
- sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
- Could not GET ‘https://mirrors.huaweicloud.com/repository/maven/com/huawei/ohos/hap/2.0.0.6/hap-2.0.0.6.pom’.
- Could not resolve com.huawei.ohos:hap:2.0.0.6.
- Could not get resource ‘https://developer.huawei.com/repo/com/huawei/ohos/hap/2.0.0.6/hap-2.0.0.6.pom’.
- Could not GET ‘https://developer.huawei.com/repo/com/huawei/ohos/hap/2.0.0.6/hap-2.0.0.6.pom’.
- sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
- Could not GET ‘https://developer.huawei.com/repo/com/huawei/ohos/hap/2.0.0.6/hap-2.0.0.6.pom’.
- Could not get resource ‘https://developer.huawei.com/repo/com/huawei/ohos/hap/2.0.0.6/hap-2.0.0.6.pom’.
- Could not resolve com.huawei.ohos:hap:2.0.0.6.
- Could not get resource ‘https://jcenter.bintray.com/com/huawei/ohos/hap/2.0.0.6/hap-2.0.0.6.pom’.
- Could not GET ‘https://jcenter.bintray.com/com/huawei/ohos/hap/2.0.0.6/hap-2.0.0.6.pom’.
- sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
- Could not GET ‘https://jcenter.bintray.com/com/huawei/ohos/hap/2.0.0.6/hap-2.0.0.6.pom’.
- Could not get resource ‘https://jcenter.bintray.com/com/huawei/ohos/hap/2.0.0.6/hap-2.0.0.6.pom’.
- Could not get resource ‘https://mirrors.huaweicloud.com/repository/maven/com/huawei/ohos/hap/2.0.0.6/hap-2.0.0.6.pom’.
- Could not resolve com.huawei.ohos:hap:2.0.0.6.
- Could not resolve com.huawei.ohos:hap:2.0.0.6.
Required by:
project :
-
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
-
Get more help at https://help.gradle.org
CONFIGURE FAILED in 2s
更多关于HarmonyOS鸿蒙Next中Gradle同步失败(unable to find valid certification path to requested target)的实战教程也可以访问 https://www.itying.com/category-93-b0.html
开发者你好,
1:外部网络访问确认网络连接无问题
2:内部网络访问需要配置代理服务器,配置代理
更多关于HarmonyOS鸿蒙Next中Gradle同步失败(unable to find valid certification path to requested target)的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
在HarmonyOS鸿蒙Next中,Gradle同步失败并出现“unable to find valid certification path to requested target”错误,通常是由于Gradle无法验证服务器的SSL证书。这可能是因为开发环境的JDK缺少必要的根证书,或者网络环境中的防火墙/代理拦截了SSL连接。
要解决此问题,可以尝试以下步骤:
-
检查网络连接:确保你的网络环境没有阻止Gradle访问远程仓库。如果使用了代理,确保代理配置正确。
-
更新JDK证书:确保你使用的JDK版本是最新的,并且包含了最新的根证书。你可以尝试更新JDK或手动导入缺失的证书。
-
禁用SSL验证:在Gradle配置文件中,可以通过添加
-Djavax.net.ssl.trustStore
参数来指定信任库,或者临时禁用SSL验证(不推荐长期使用)。 -
使用本地仓库:如果你有本地Maven仓库,可以尝试配置Gradle使用本地仓库,避免从远程仓库下载依赖。
-
检查Gradle配置:确保你的
build.gradle
文件中没有错误的仓库地址或配置。
通过上述步骤,通常可以解决Gradle同步失败的问题。如果问题仍然存在,可能需要进一步检查网络环境或开发工具配置。
在HarmonyOS鸿蒙Next中,Gradle同步失败并提示"unable to find valid certification path to requested target",通常是由于Gradle无法验证SSL证书导致的。解决方法如下:
- 检查网络代理:确保网络代理未拦截或修改SSL证书。
- 更新JDK证书:将最新的CA证书导入JDK的
cacerts
文件中。 - 禁用SSL验证:在
build.gradle
中添加allowInsecureProtocol = true
,但此方法不推荐用于生产环境。 - 使用HTTP:将仓库URL从HTTPS改为HTTP,但同样不推荐。
建议优先更新JDK证书或检查网络配置。