Android Studio引用远程依赖包时下载不了jar包的解决方法

有一个工程使用了远程的jar包,报错如下

报错信息:

Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_ProcDebugApkCopy'.
   > Could not resolve com.android.support:appcompat-v7:27.0.2.
     Required by:
         project :app
      > Could not resolve com.android.support:appcompat-v7:27.0.2.
         > Could not get resource 'https://maven.google.com/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom'.
            > Could not GET 'https://maven.google.com/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom'.
               > Remote host closed connection during handshake
   > Could not resolve com.android.support:recyclerview-v7:26.0.0.
     Required by:
         project :app
      > Could not resolve com.android.support:recyclerview-v7:26.0.0.
         > Could not get resource 'https://maven.google.com/com/android/support/recyclerview-v7/26.0.0/recyclerview-v7-26.0.0.pom'.
            > Could not GET 'https://maven.google.com/com/android/support/recyclerview-v7/26.0.0/recyclerview-v7-26.0.0.pom'.
               > Remote host closed connection during handshake
   > Could not resolve com.android.support:support-v4:26.0.0.
     Required by:
         project :app
      > Could not resolve com.android.support:support-v4:26.0.0.
         > Could not get resource 'https://maven.google.com/com/android/support/support-v4/26.0.0/support-v4-26.0.0.pom'.
            > Could not GET 'https://maven.google.com/com/android/support/support-v4/26.0.0/support-v4-26.0.0.pom'.
               > Remote host closed connection during handshake
   > Could not resolve com.android.support:design:26.0.0.
     Required by:
         project :app
      > Could not resolve com.android.support:design:26.0.0.
         > Could not get resource 'https://maven.google.com/com/android/support/design/26.0.0/design-26.0.0.pom'.
            > Could not GET 'https://maven.google.com/com/android/support/design/26.0.0/design-26.0.0.pom'.
               > Remote host closed connection during handshake
   > Could not resolve com.android.support:appcompat-v7:27.0.2.
     Required by:
         project :app > com.kyleduo.switchbutton:library:1.4.6
      > Could not resolve com.android.support:appcompat-v7:27.0.2.
         > Could not get resource 'https://maven.google.com/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom'.
            > Could not GET 'https://maven.google.com/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom'.
               > Remote host closed connection during handshake
   > Could not resolve com.android.support:appcompat-v7:27.0.2.
     Required by:
         project :app > com.airbnb.android:lottie:2.5.0
      > Could not resolve com.android.support:appcompat-v7:27.0.2.
         > Could not get resource 'https://maven.google.com/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom'.
            > Could not GET 'https://maven.google.com/com/android/support/appcompat-v7/27.0.2/appcompat-v7-27.0.2.pom'.

               > Remote host closed connection during handshake

 

 

原来的build.gradle配置为:

 

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

从错误信息上可以看出,访问https://maven.google.com/时Remote host closed connection during handshake(访问握手期间远程主机关闭连接),被墙了!

改下,用下面的配置:

 

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        google()
    }
}

高版本的gradle尽量避免使用静态的url地址,配置完clean后重新编译,没问题了!

gradle4.0推荐使用google()

 

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值