美文网首页Android 音视频开发
Android studio gradle下载设置

Android studio gradle下载设置

作者: 古风子 | 来源:发表于2020-02-08 16:33 被阅读0次

国内网络,下载gradle和相关依赖库,十分缓慢,而且大概率会下载超时,常常抛出以下错误

Could not get resource 'https://jcenter.bintray.com/...'

解决方案:
使用阿里云的代理服务器,配置方法如下.
打开工程的build.gradle文件,增加阿里云的maven仓库地址

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
      // 以下四行代码为阿里gradle 源
        maven{ url 'https://maven.aliyun.com/repository/google'}
        maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
        maven{ url 'https://maven.aliyun.com/repository/public'}
        maven{ url 'https://maven.aliyun.com/repository/jcenter'}
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'

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

allprojects {
    repositories {
       // 以下四行代码为阿里gradle 源
        maven{ url 'https://maven.aliyun.com/repository/google'}
        maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
        maven{ url 'https://maven.aliyun.com/repository/public'}
        maven{ url 'https://maven.aliyun.com/repository/jcenter'}
        google()
        jcenter()





    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

相关文章

网友评论

    本文标题:Android studio gradle下载设置

    本文链接:https://www.haomeiwen.com/subject/ecvixhtx.html