IntelliJ HTTP-Proxy works but fails at gradle depe

2019-04-26 03:39发布

问题:

so currently at work I face the problem, that I cannot build projects, which use global dependencies. We use an auto-config proxy script, which I already set in the File->Settings->Appearance & Behaviour->System Settings->HTTP Proxy and tested with the Check Connection-function.

The check connection function is working for any arbitrary html and also for the needed gradle-file (jcenter.bintray.com/com/android/tools/build/gradle/2.0.0/gradle-2.1.0-javadoc.jar).

For solutions I already tried to:

  • set the Proxy Information into the gradle.properties
  • tried to set http and/or https proxy settings

    * systemProp.http(s).proxyHost=linktoproxyconfig.org  
    * systemProp.http(s).proxyPort=xxxx                 
    * systemProp.http(s).proxyUser=xxxx            
    * systemProp.http(s).proxyPassword=xxxx
    
  • changing the repository direction (jcenter() vs. jcenter{url http://jcenter.bintray.com}

I am aware of the fact, that one can work offline, downloading the gradle locally. But to prevent the additional maintenance of gradle versions on different machines I would like to restrain from the work offline option.

Edit: Maybe I should also add the error message:
Gradle sync failed: Connection timed out: connect. If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle.

I would be most grateful if someone has an idea about a solution.

回答1:

IntelliJ IDEA 2017.3 does not seem to respect the proxy options for downloading Gradle. So add the proxy options to both gradle.properties and gradle-wrapper.properties, and then run ./gradlew in a terminal. This will download Gradle. After that, IntelliJ will work.



回答2:

It also happend to me and the problem was that Gradle installation was wrong. I added a GRADLE_HOME environment variable and appended %GRADLE_HOME%/bin to PATH. I restarted the IDE and it worked! :)

Source: https://docs.gradle.org/current/userguide/installation.html#sec:installation_environment_variables