> 文档中心 > 【HarmonyOS】【FAQ】DevEco Studio 提示“Using insecure protocols with repositories, without explicit opt-in

【HarmonyOS】【FAQ】DevEco Studio 提示“Using insecure protocols with repositories, without explicit opt-in

【问题描述】

因为工作需要,运行一个低版本(api 6)穿戴设备的demo,build工程时编译失败报错:

cke_219.png

Using insecure protocols with repositories, without explicit opt-in, is unsupported.

> Solution: Please switch Maven repository 'maven(http://jcenter.bintray.com)' to redirect to a secure protocol (like HTTPS), or allow insecure protocols

根据工程报错提示,判断是由于maven仓地址没有使用https造成的,但是工程中的仓库地址都是https的且没有jcenter仓库,需要进一步研究。

【解决方案】

因为工程中没有配置jcenter仓库,怀疑时gradle全局配置中包含了jcenter的地址,引起了这个问题。终于在系统gradle文件配置目录中(C:Users\用户名\.gradle\init.gradle)找了jcenter的相关代码

allprojects{    repositories { def REPOSITORY_URL = 'http://jcenter.bintray.com' all { ArtifactRepository repo ->     if(repo instanceof MavenArtifactRepository){  def url = repo.url.toString()  if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')) {      project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."      remove repo  }     } } maven {     url REPOSITORY_URL }    }}

将配置文件的最后一个block修改为

 maven {     url REPOSITORY_URL     allowInsecureProtocol = true }

重新编译终于解决了问题,工程可以正常运行。

欲了解更多更全技术文章,欢迎访问https://developer.huawei.com/consumer/cn/forum/?ha_source=zzh