DevEco Studio 提示“Using insecure protocols with repositories, without explicit opt-in, is unsupported. ”

DevEco Studio 提示“Using insecure protocols with repositories, without explicit opt-in, is unsupported. ” 【问题描述】

因为工作需要,运行一个低版本(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        }

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


1 回复

该提示信息“Using insecure protocols with repositories, without explicit opt-in, is unsupported.”意味着DevEco Studio在构建过程中检测到仓库使用了不安全的协议,且没有明确的启用许可。这通常是因为在项目的构建配置(如build.gradle文件)中引用了使用HTTP协议而非HTTPS协议的仓库地址。

为了解决这个问题,你需要检查并更新项目中的仓库地址,确保所有外部依赖都通过HTTPS协议访问。具体步骤如下:

  1. 打开DevEco Studio中的项目。
  2. 在项目的根目录下找到并打开build.gradle文件(通常是项目级别的,而非模块级别的)。
  3. 检查repositories块中的所有仓库地址,将HTTP协议替换为HTTPS协议。
  4. 保存更改并重新同步项目。

例如,如果原来的配置是:

repositories {
    maven {
        url "http://some-insecure-repo.com/repo"
    }
}

应修改为:

repositories {
    maven {
        url "https://some-secure-repo.com/repo"
    }
}

注意,如果仓库地址本身不支持HTTPS,你可能需要联系仓库管理员或寻找其他安全的仓库源。

如果问题依旧没法解决请联系官网客服,官网地址是 https://www.itying.com/category-93-b0.html

回到顶部