一、报错信息
could not resolve com.android.tools.build:gradle:4.1.1.
其实是因为你的网络不能从AS工程提供的mavenCentral()、google()和jcenter()等仓库下载相应的依赖。
二、解决方法
在build.gradle(Project)中,在原先的maven仓库前加上阿里云镜像源。这里由于AS工程中引入了其他框架,有固定的引用写法,所以在buildscript
中不要加上maven { url 'https://www.jitpack.io' }
。
buildscript {repositories {maven { url 'https://maven.aliyun.com/repository/public' }maven { url 'https://maven.aliyun.com/repository/central' }maven { url 'https://maven.aliyun.com/repository/jcenter' }maven { url 'https://maven.aliyun.com/repository/google' }maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }mavenCentral()google()jcenter()}dependencies {classpath "com.android.tools.build:gradle:4.1.1"// NOTE: Do not place your application dependencies here; they belong// in the individual module build.gradle files}
}allprojects {repositories {maven { url 'https://www.jitpack.io' }maven { url 'https://maven.aliyun.com/repository/public' }maven { url 'https://maven.aliyun.com/repository/central' }maven { url 'https://maven.aliyun.com/repository/jcenter' }maven { url 'https://maven.aliyun.com/repository/google' }maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }mavenCentral()google()jcenter()}
}task clean(type: Delete) {delete rootProject.buildDir
}
再次同步,可以看到成功下载依赖。
《寿康宝鉴》http://www.shoukangbaojian.com/
《欲海回狂》http://www.yuhaihuikuang.com/
《了凡四训》https://www.zhonghuadiancang.com/rulizhexue/liaofansixun/