Allen 专栏-移动互联网

Android Architecture Components 1 标签

Android Architecture Component https://maven.google.com 404? 有更新!

最近想要 研究####Android Architecture Components 奈何本地的gradle一直拉不下源码,尝试切换到云服务器编译,依然落不下代码 提示错误

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
   > Could not resolve android.arch.persistence.room:runtime:1.0.0-alpha3.
     Required by:
         project :app
      > Could not resolve android.arch.persistence.room:runtime:1.0.0-alpha3.
         > Could not get resource 'https://maven.google.com/android/arch/persistence/room/runtime/1.0.0-alpha3/runtime-1.0.0-alpha3.pom'.
            > Could not HEAD 'https://maven.google.com/android/arch/persistence/room/runtime/1.0.0-alpha3/runtime-1.0.0-alpha3.pom'.
               > Connect to maven.google.com:443 [maven.google.com/216.58.200.46] failed: Connection timed out: connect
   > Could not resolve android.arch.lifecycle:common:1.0.0-alpha3.
     Required by:
         project :app > android.arch.lifecycle:runtime:1.0.0-alpha3
         project :app > android.arch.lifecycle:extensions:1.0.0-alpha3
      > Could not resolve android.arch.lifecycle:common:1.0.0-alpha3.
         > Could not get resource 'https://maven.google.com/android/arch/lifecycle/common/1.0.0-alpha3/common-1.0.0-alpha3.pom'.
            > Could not HEAD 'https://maven.google.com/android/arch/lifecycle/common/1.0.0-alpha3/common-1.0.0-alpha3.pom'.
               > Connect to maven.google.com:443 [maven.google.com/216.58.200.46] failed: Connection timed out: connect


思来想去,还是没找到原因,本身网络是自带翻墙梯子的,后来看到很多人在Google issue提问题,也是无法下载依赖库
后来尝试翻看 https://developer.android.com/studio/build/dependencies.html 找到了答案,Google 建议将

https://maven.google.com
替换为 https://dl.google.com/dl/android/maven2/

答案解析 https://developer.android.com/studio/build/dependencies.html

repositories {
    maven {
        url 'https://maven.google.com'
        // Alternative URL is 'https://dl.google.com/dl/android/maven2/'
    }
}