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

Android Studio引用远程依赖包时下载不了jar包的解决方法_第1张图片

报错信息:

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()

 

更多相关文章

  1. android中的类加载和静态成员变量的初始化
  2. 赵雅智_名片夹(4)_Android中listview可折叠伸缩仿手风琴效果(静态)
  3. Android–带有动态库、静态库、Jar包的makefile编写
  4. Android真机调试——远程主机强迫关闭了一个现有的连接。
  5. marsboard Android 4.4 添加开机自动设置静态IP地址
  6. android NDK编译.a静态库
  7. Android静态安全检测 -> 证书弱校验
  8. so文件静态分析&&Android录屏技术
  9. Android的联通性---USB主机模式(一)

随机推荐

  1. 如何用命令(cmd)创建开启AVD
  2. 【Android 电量优化】电量优化 ( Battery
  3. 更改.android目录位置
  4. 去除警告 Android(安卓)NDK: WARNING: AP
  5. Android(安卓)Didn't find class "xxx某
  6. layui 上传图片 移动端 调用相机
  7. android的surfaceflinger原理讲解
  8. android   动态改变图片大小
  9. Android到Androidx记录
  10. android:windowSoftInputMode 介绍