AS解决阿里云的http或https的问题,Using insecure protocols with repositories, without explicit opt-in,

首先说表达一下,真的是太恶心了,网上说的很多的方法都是不靠谱的。

下面我展示我的绝招。

1、在C:\Users\XXX\.gradle的init.gradle文件中添加一行代码:allowInsecureProtocol = true(切记有等于号)

allprojects{
    repositories {
        def ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public'
        def ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
        all { ArtifactRepository repo ->
            if(repo instanceof MavenArtifactRepository){
                def url = repo.url.toString()
                if (url.startsWith('https://repo1.maven.org/maven2')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
                    remove repo
                }
                if (url.startsWith('https://jcenter.bintray.com/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
                    remove repo
                }
            }
        }
        maven {
		    allowInsecureProtocol = true  //就是这一行
            url ALIYUN_REPOSITORY_URL
            url ALIYUN_JCENTER_URL
        }
    }
}

2、在项目的根目标下的build.gradle中修改:allowInsecureProtocol true(切记无等于号),此外将http改为https

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            allowInsecureProtocol true //就是这一行
            url "https://jitpack.io"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            allowInsecureProtocol true //就是这一行
            url 'https://maven.aliyun.com/nexus/content/groups/public/'
        }

    }
}


然后就是好好的等待问题重新构建

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 Maven 项目构建过程中,如果出现报错"Using insecure protocols with repositories, without explicit opt-in, is unsupported",这是由于使用了不安全的协议连接仓库所致。为了解决这个问题,有几种方法可以尝试。 首先,可以通过在 Maven 配置中添加关键字"allowInsecureProtocol"来允许使用不安全的协议。例如,可以在 Maven 配置文件中添加以下代码: ```groovy maven { allowInsecureProtocol = true url 'xxx' } ``` 其中,'xxx'是你要连接的仓库地址。这样就可以允许使用不安全的协议连接该仓库了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Gradle报错 Using insecure protocols with repositories, without explicit opt-in, is unsupported.](https://blog.csdn.net/xiaopihair123/article/details/127530717)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven...](https://blog.csdn.net/qq_22255311/article/details/122600752)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值