Using Gradle from behind a proxy

By default Android Studio uses Gradle to build Android projects. This means Android Studio always needs a connection to the internet to check for and retrieve dependencies. If you’re developing from behind a proxy (as I am) then you’ll have to explicitly tell Gradle the proxy details to allow it to connect to its servers.

Steps to fix

  1. Navigate to the “.gradle” folder in your user directory (e.g. C:\Users\bob\.gradle)
  2. Create a “gradle.properties” file
  3. Edit the file to have the following contents (replacing your own values)
systemProp.http.proxyHost=<proxy_host>
systemProp.http.proxyPort=<port>
systemProp.http.proxyUser=<user>
systemProp.http.proxyPassword=<password>
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost

Gradle should then succeed on the next build.

Note – thanks go to Steve Hanson for these steps.

Update 08 Dec 2014 – As of the update to Android 1.0, these steps are not enough! I’ve documented the new definitive list in this post.

1 thought on “Using Gradle from behind a proxy”

  1. Pingback: Gradle from behind a proxy, part deux | Seb Charrot

Leave a Reply

Your email address will not be published. Required fields are marked *