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

声明:该博文参考了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
    }
}

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