升级到 Gradle 6 & Android Gradle 插件 4.0.0 无法获取 "https://dl.google.com/android/repository/addons_list-3.xml"

Upgrade to Gradle 6 & Android Gradle Plugin 4.0.0 fails to fetch "https://dl.google.com/android/repository/addons_list-3.xml"

我为我的 Android 项目配置了 CI。

构建项目的服务器无法上网。所以,我得到这个错误:

 IOException: https://dl.google.com/android/repository/addons_list-3.xml
 java.net.ConnectException: Connection timed out (Connection timed out)

项目build.gradle文件中的所有存储库声明如下:

repositories {
    maven("https://artifactory.mycompany.com/artifactory/jfrog-gradle-plugins")
    maven("https://artifactory.mycompany.com/artifactory/maven-fabric")
    maven("https://artifactory.mycompany.com/artifactory/remote-repos")
    maven("https://artifactory.mycompany.com/artifactory/google-maven")
    maven("https://artifactory.mycompany.com/artifactory/jcenter")
    maven("https://artifactory.mycompany.com/artifactory/libs-android")
}

当我将 Gradle Wrapper 升级到 6.1.1 和 Android Gradle 插件 4.0.0.

时出现此错误

主要变化是此处描述的变化:

https://docs.gradle.org/6.0/userguide/declaring_repositories.html#sec:supported_metadata_sources

..也就是说,我将这些选项添加到我的存储库中,因为我有 artifacts/libraries 而没有 pom.xml 文件。

    metadataSources {
        mavenPom()
        artifact()
    }

因此,我认为上述更改使 Gradle 插件可以尝试从

下载内容

https://dl.google.com/android/repository/addons_list-3.xml

但我无法确认是这个原因。

原来我的 CI 设置使用的构建机器配置了构建工具版本 29.0.0,然后最新的 Android Gradle 插件 (4.0.0) 正在尝试下载最新的 android 构建工具 (29.0.2)。

更新构建机器中的 android 构建工具后,一切正常。