AS build安卓项目出现“Read timed out”错误

错误日志

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
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

丧心病狂の程序员

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值