6

I have read multiple similar questions and the documentation but I have not been able to solve my issue of getting by the corporate firewall my machine sits behind. The error I am getting is 'Failed to refresh Gradle project' Unknown host services.gradle.org. Everything I have read and understand lead me to believe this is a http proxy issue. I have tried setting the proxy properties in the gradle.properties file in my Project folder so my gradle.properties file looks like :

# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Settings specified in this file will override any Gradle settings
# configured through the IDE.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -    Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
#  http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

systemProp.http.proxyHost=proxy.company.com
systemProp.http.proxyPort=83
systemProp.http.proxyUser=username
systemProp.http.proxyPassword=password
systemProp.http.auth.ntlm.domain=domain

systemProp.https.proxyHost=proxy.company.com
systemProp.https.proxyPort=83
systemProp.https.proxyUser=username
systemProp.https.proxyPassword=password
systemProp.https.auth.ntlm.domain=domain

I have also tried setting the Global Gradle Settings by going File->Settings->Gradle and setting the Gradle VM Options using:

-Dhttp.proxyHost=proxy.company.com -Dhttp.proxyPort=83 -Dhttp.proxyUser=username -Dhttp.proxyPassword=password

I cannot see any documentation of where else to set this http proxy setting, please help if you can.

OhWhen
  • 91
  • 1
  • 2
  • 5

5 Answers5

3

try to add domain into gradle global settings

-Dhttp.proxyHost=proxy.company.com -Dhttp.proxyPort=83 -Dhttp.proxyUser=username -Dhttp.proxyPassword=password -Dhttp.auth.ntlm.domain=domain

It helps for me.

MarkosyanArtur
  • 1,359
  • 13
  • 10
  • I've tried all of this and now I'm getting the following error: Gradle 'HelloWorld' project refresh failed Error:Error:Unable to start the daemon process. This problem might be caused by incorrect configuration of the daemon. – bolski Oct 23 '14 at 12:00
  • For example, an unrecognized jvm option is used. Please refer to the user guide chapter on the daemon at http://gradle.org/docs/1.12/userguide/gradle_daemon.html Please read below process output to find out more: ----------------------- 08:00:04.610 [main] DEBUG o.g.l.daemon.bootstrap.DaemonMain - Assuming the daemon was started with following jvm opts: [-XX:MaxPermSize=256m, -XX:+HeapDumpOnOutOfMemoryError, -Xmx1024m, -Dfile.encoding=windows-1252] FAILURE: Build failed with an exception. * What went wrong: – bolski Oct 23 '14 at 12:02
  • Could not create service of type DaemonContext using DaemonServices.createDaemonContext(). * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. – bolski Oct 23 '14 at 12:03
2
//gradle.properties

systemProp.http.proxyHost=www.somehost.org

systemProp.http.proxyPort=8080

systemProp.http.proxyUser=userid

systemProp.http.proxyPassword=password

systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost
xlecoustillier
  • 16,183
  • 14
  • 60
  • 85
Viswa
  • 21
  • 2
1

All you need to do is to go to Settings at File and choose Auto detect proxy and test connection for goole.com or your website domain.

Kofi Sammie
  • 3,237
  • 1
  • 17
  • 17
0

Had a similar issue getting android studio to open up behind a corporate firewall. It would crash after looking for SDK updates and failing. I used a freeware called "proxycap" and input the proxy settings for the corporation (available in the my computer's internet settings). Now it works fine! There are other proxy freewares (proxify...), but I chose this is one of the programs with a program level proxy settings, where I could set up the proxy for android studio only.

samutopia
  • 21
  • 2
  • Worked for me using ProxyCap. People say a new user and downvoted without trying. This is probably the best option as I don't need to find config files in the future. –  Jan 23 '15 at 04:02
0

I dont know if there was proxy option in previous version, but in v1.0.1 and above you can find it in File-> Settings -> IDE settings.

Shaji Thorn Blue
  • 589
  • 2
  • 9
  • 19