Android Studio Connect to repo.maven.apache.org:443 failed: Connection time

文章指导如何在AndroidStudio中设置阿里云镜像作为代理,以解决远程仓库下载问题。主要方法是修改项目的build.gradle文件,将仓库地址替换为阿里云的镜像URL,包括对google(),mavenCentral()和jcenter()的处理。此外,提醒注意即将关闭的jcenter()仓库。

声明:该博文参考了Android Studio 设置阿里云镜像代理(如果设置之后还是远程仓库下载失败,请仔细阅读其内容就可以解决了)若原博客主人觉得侵权了,请联系,该博客就删除。

目的:方便遇到类似问题的人,可以少走弯路。

问题:如图所示:

 解决方法:按照Android Studio 设置阿里云镜像代理(如果设置之后还是远程仓库下载失败,请仔细阅读其内容就可以解决了)提到的方法。修改了整个项目的build.gradle两处,如下:

buildscript {
    repositories {
        maven{ url 'https://maven.aliyun.com/repository/google'} //修改1
        maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'} //修改1
        maven{ url 'https://maven.aliyun.com/repository/public'} //修改1
        maven{ url 'https://maven.aliyun.com/repository/jcenter'} //修改1
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.2.2"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven{ url 'https://maven.aliyun.com/repository/google'} //修改2
        maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'} //修改2
        maven{ url 'https://maven.aliyun.com/repository/public'} //修改2
        maven{ url 'https://maven.aliyun.com/repository/jcenter'} //修改2
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
    }
}

文件具体位置如下图所示:

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值