几行代码教你解决Android studio中gradle同步过慢的问题

问题描述

Android studio更新中,gradle文件的更新过慢

问题解决

该问题原因就是是国内访问jcenter太慢,甚至连接不上,就会报各种关于依赖更新失败的错误。

笔者推荐使用阿里云镜像,只需要添加相应的url地址就可以下载;

  1. 打开项目gradle scripts–>build gradle文件,将如下代码添加到原代码上方。
buildscript {

    repositories {
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'


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

allprojects {
    repositories {
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        google()
        jcenter()
    }
}

你可能感兴趣的:(安卓开发,问题解决)