错误日志
org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring root project 'TextureMusic'.
Caused by: org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'TextureMusic'.
... 75 more
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all artifacts for configuration ':classpath'.
Caused by: org.gradle.internal.resolve.ArtifactResolveException: Could not download freemarker.jar (org.freemarker:freemarker:2.3.23)
Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'https://jcenter.bintray.com/org/freemarker/freemarker/2.3.23/freemarker-2.3.23.jar'.
Caused by: java.net.SocketTimeoutException: Read timed out
... 47 more
错误原因
由于网络限制,或者外网下载网速过慢的情况。会导致google或者jcenter库的aar,jar库文件无法下载。
解决方法
在项目project的build.gradle下配置成阿里或其他可达的镜像服务器
具体代码
这里以替换阿里源为例,添加:
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
到google,jcenter repositories之前,完整build.gradle 文件如下:
buildscript {
repositories {
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.vanniktech:gradle-android-junit-jacoco-plugin:0.11.0'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
url 'http://maven.aliyun.com/nexus/content/groups/public/'
}
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}