gradle同步特别慢,网上收集的几种方法。
android/build.gradle
repositories { maven { url 'https://maven.aliyun.com/repository/jcenter' } maven { url 'https://maven.aliyun.com/repository/google' } jcenter() google() }
第二个比较完整,推荐
buildscript { ext.kotlin_version = '1.2.71' 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' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { // 所有的model 都优先使用阿里源 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 }