解决Android Studio应用构建速度慢的问题

前些天应为AS自动的模拟器总连不上本地PC机的网络,不管是用10.0.2.2还是本地IP地址都不能访问,因此卸载重装了最新版的AS。 重装后编译第一个App时,需要下载好多依赖包,网速奇慢无比,最终找到设置镜像代理的方法解决该问题,镜像配置的方法比设置网络代理更方便好用。 镜像地址的说明可参考 阿里云云效 Maven

gradle6.x 配置文件
···
buildscript {

repositories {
    maven{ url 'https://maven.aliyun.com/repository/google'}
    maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
    maven{ url 'https://maven.aliyun.com/repository/central'}
    maven { url 'https://maven.aliyun.com/repository/public' }
    google()
    jcenter()
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:4.2.2'
    // 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/gradle-plugin’}
maven{ url ‘https://maven.aliyun.com/repository/central’}
maven { url ‘https://maven.aliyun.com/repository/public’ }
google()
jcenter()
mavenCentral()
}
}
···

gradle7.x 配置文件
···
pluginManagement {
repositories {
maven{ url ‘https://maven.aliyun.com/repository/google’}
maven{ url ‘https://maven.aliyun.com/repository/gradle-plugin’}
maven{ url ‘https://maven.aliyun.com/repository/central’}
maven { url ‘https://maven.aliyun.com/repository/public’ }
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
maven{ url ‘https://maven.aliyun.com/repository/google’}
maven{ url ‘https://maven.aliyun.com/repository/gradle-plugin’}
maven{ url ‘https://maven.aliyun.com/repository/central’}
maven { url ‘https://maven.aliyun.com/repository/public’ }
google()
mavenCentral()
}
}
···

参考链接 :Android Studio 设置阿里云镜像代理(如果设置之后还是远程仓库下载失败,请仔细阅读其内容就可以解决了)_android studio 阿里云镜像_ErwinNakajima的博客-CSDN博客

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值