AS build Androidプロジェクトで「Read timed out」エラーが発生

2210 ワード

エラーログ
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ライブラリファイルがダウンロードできません.
解決策
プロジェクトの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
}