Error:Unknown host services.gradle.org. You may need to adjust the proxy settings in Gradle

后端 未结 16 2054
有刺的猬
有刺的猬 2020-12-15 08:38

i have tried it many times but its giving me same error.how to set the proxy so that this error is solved

相关标签:
16条回答
  • 2020-12-15 08:44

    Android Plugin for Gradle HTTP proxy settings

    For application-specific HTTP proxy settings, set the proxy settings in the build.gradle file as required for each application module.

    apply plugin: 'com.android.application'
    
    android {
        ...
    
        defaultConfig {
            ...
            systemProp.http.proxyHost=proxy.company.com
            systemProp.http.proxyPort=443
            systemProp.http.proxyUser=userid
            systemProp.http.proxyPassword=password
            systemProp.http.auth.ntlm.domain=domain
        }
        ...
    }
    

    For project-wide HTTP proxy settings, set the proxy settings in the gradle/gradle.properties file.

    # Project-wide Gradle settings.
    ...
    
    systemProp.http.proxyHost=proxy.company.com
    systemProp.http.proxyPort=443
    systemProp.http.proxyUser=username
    systemProp.http.proxyPassword=password
    systemProp.http.auth.ntlm.domain=domain
    
    systemProp.https.proxyHost=proxy.company.com
    systemProp.https.proxyPort=443
    systemProp.https.proxyUser=username
    systemProp.https.proxyPassword=password
    systemProp.https.auth.ntlm.domain=domain
    
    ...
    

    Please read Official Document Configuration

    0 讨论(0)
  • 2020-12-15 08:46

    Preferences --> Build, Execution, Deployment --> Gradle --> Android studio

    0 讨论(0)
  • 2020-12-15 08:47

    For some reason, using a shared machine, I couldn`t figure out where this proxy properties is comming from.

    So a workaround to fix this is add in you project gradle.properties the following (empty properties). So It will override top hierarchy configuration:

    systemProp.http.proxyPort=
    systemProp.http.proxyUser=
    systemProp.http.proxyPassword=
    systemProp.https.proxyPassword=
    systemProp.https.proxyHost=
    systemProp.http.proxyHost=
    systemProp.https.proxyPort=
    systemProp.https.proxyUser=
    
    0 讨论(0)
  • 2020-12-15 08:49

    Everyone: I Solved the problem like this. In Android Studio go to File menu and select the Invalidate Caches/Restart... I hope it will work for you. Thanks

    0 讨论(0)
  • 2020-12-15 08:50

    Download a recent gradle release from gradle.org/releases Unzip the file and copy the gradle folder e.g. gradle 4.0 into C -- program files -- android -- android studio -- gradle. On your android studio goto file -- settings -- Build, Execution, Deployment --Build Tools -- Gradle and choose Use local gradle distribution, in the gradle home locate your gradle folder and click apply. Then click okay. This solved the problem for me. Your android studio might require a more recent gradle release, make sure you download a gradle that is compatible with your studio or latest releases.

    0 讨论(0)
  • 2020-12-15 08:52

    In my case issue occurred after following:

    I selected proxy settings from Android Studio settings when I was working in a network behind a proxy. When I disconnected from that network and connected to home network which doesn't have a proxy, I removed the proxy settings from Android Studio, but gradle seemed to take the old proxy settings.

    The problem was that gradle had also saved the proxy settings in following file when I set proxy settings in Android Studio, but it hasn't got removed when I removed proxy settings from Android Studio.

    %HOME%\.gradle\gradle.properties
    

    When I removed the proxy settings from this file, gradle sync worked again.

    0 讨论(0)
提交回复
热议问题