android 工作室连接被拒绝:将类路径添加到顶级根构建时连接 gradle

android studio connection refused: connect when add classpath to top root build gradle

我正在尝试将类路径 'com.google.gms:google-services:3.0.0' 添加到 build.gradle 根文件,但出现错误

错误:连接被拒绝:连接

当我更改应用程序 gradle 文件时,它仅适用于顶级根 gradle 文件,我收到此错误。

我使用在 gradle.properties

中配置的代理
systemProp.http.proxyPassword=****han1987
systemProp.http.proxyHost=*****
org.gradle.jvmargs=-Xmx1536m
systemProp.http.proxyUser=***amassi
systemProp.http.proxyPort=8080

我的build.gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
} 

task clean(type: Delete) {
    delete rootProject.buildDir
}

我终于找到了解决办法 我有

 systemProp.http.proxyPassword=****han1987
 systemProp.http.proxyHost=*****
 org.gradle.jvmargs=-Xmx1536m
 systemProp.http.proxyUser=***amassi
 systemProp.http.proxyPort=8080

我这样添加 https :

 systemProp.https.proxyPassword=****han1987
 systemProp.https.proxyHost=*****
 systemProp.https.proxyUser=***amassi
 systemProp.https.proxyPort=8080

它解决了我的问题,但我不明白为什么它适用于应用程序而不适用于应用程序根目录。