修改android studio 新建项目的build.gradle的仓库源
1. 找到你们的android studio 安装的路径
例如, 我的的路径是:D:\Android Studio\plugins\android\lib\templates\gradle-projects\NewAndroidProject\root\
2. 打开该路径下的build.gradle.ftl 文件
3.修改build.gradle.ftl文件
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
<#if generateKotlin>ext.kotlin_version = '${kotlinVersion}'</#if>
repositories {
maven {url 'https://maven.aliyun.com/repository/google' }
maven {url 'https://maven.aliyun.com/repository/jcenter'}
<#if includeKotlinEapRepo!false>maven { url '${kotlinEapRepoUrl}' }</#if>
}
dependencies {
classpath 'com.android.tools.build:gradle:${gradlePluginVersion}'
<#if generateKotlin>classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"</#if>
// 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' }
maven {url 'https://maven.aliyun.com/repository/jcenter'}
<#if includeKotlinEapRepo!false>maven { url '${kotlinEapRepoUrl}' }</#if>
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
加粗为修改之后的,原先是 Google自家的扩展依赖库google()和第三方的开源库jcenter()。修改之后的是国内阿里镜像源。国内镜像好处就是build gradle速度快,不像国外镜像,有些下载不了文件,会卡在那。
本文地址:https://blog.csdn.net/qq_22488067/article/details/107208925