升级Android Studio 后项目编译太慢 解决办法
- 下载资源太慢
解决办法,使用国内阿里镜像资源
allprojects {
repositories {
maven { url ‘https://maven.aliyun.com/nexus/content/repositories/google’ }
maven { url ‘https://maven.aliyun.com/nexus/content/groups/public/’ }
maven { url ‘https://maven.aliyun.com/nexus/content/repositories/jcenter’}
2,非第一次编译项目,build时间过长
-
设置离线模式
–offline
位置在 Settings–》Build、Execution、Deployment–》Compiler
下的Command-line Options 填写 --offline
-
在User/.gradle/ 目下建一个gradle.properties文件 内容如下`
org.gradle.daemon=true
- 在User/.gradle/ 目下建一个init.gradle文件 内容如下
allprojects{
repositories {
def ALIYUN_REPOSITORY_URL = 'https://maven.aliyun.com/repository/public'
def ALIYUN_JCENTER_URL = 'https://maven.aliyun.com/repository/jcenter'
def ALIYUN_GOOGLE_URL = 'https://maven.aliyun.com/repository/google'
all { ArtifactRepository repo ->
if(repo instanceof MavenArtifactRepository){
def url = repo.url.toString()
if (url.startsWith('https://repo1.maven.org/maven2')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
remove repo
}
if (url.startsWith('https://jcenter.bintray.com/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
remove repo
}
if (url.startsWith('https://maven.google.com/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_GOOGLE_URL."
remove repo
}
}
}
maven {
url ALIYUN_REPOSITORY_URL
url ALIYUN_JCENTER_URL
url ALIYUN_GOOGLE_URL
}
}
}