有一個工程使用了遠程的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()
}
}
儘量避免使用靜態的url地址,配置完clean後重新編譯,沒問題了