找下面路径的文件
D:\AndroidStudio\plugins\android\lib\templates\gradle-projects\NewAndroidProject\root\build.gradle.ftl
注意这里是以我本机安装的AndroidStudio为例,你需要将安装路径换成你本机的路径,另外我的系统是win10,Android Studio版本为3.5.2
修改如下:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
<#macro loadProperties>
<#if useOfflineRepo!false>
Properties properties = new Properties()
properties.load(project.rootProject.file("local.properties").newDataInputStream())
</#if>
</#macro>
<#macro useProperties>
<#if useOfflineRepo!false>
properties.getProperty("offline.repo").split(",").each { repo ->
maven { url repo }
}
</#if>
</#macro>
buildscript {<#if includeKotlinSupport!false>
ext.kotlin_version = '${kotlinVersion}'</#if>
<@loadProperties/>
repositories {
<@useProperties/>
maven { url 'https://plugins.gradle.org/m2/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
<#if includeKotlinEapRepo!false>maven { url '${kotlinEapRepoUrl}' }</#if>
}
dependencies {
classpath 'com.android.tools.build:gradle:${gradlePluginVersion}'
<#if includeKotlinSupport!false>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 {
<@loadProperties/>
repositories {
<@useProperties/>
maven { url 'https://plugins.gradle.org/m2/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
<#if includeKotlinEapRepo!false>maven { url '${kotlinEapRepoUrl}' }</#if>
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
来源:oschina
链接:https://my.oschina.net/php7/blog/3197310