Skip to content

Set Different Gradle Configurations

September 19th, 2016 - ITTutorial(1 min)

TL;DR: create a global file (in <HOME>/.gradle or GRADLE_USER_HOME if defined). Place there the system specific configuration.

The other day I had the unpleasant surprise that Android Studio replicated my proxy settings into and got committed to Git. Including a password (which has since became obsolete). Since my other environment doesn’t use a proxy, I got an error there. Now, the question became:

How do I create a single project gradle settings file which would allow me to run smoothly in both places?

Although I thought of a command line things, the answer is much simpler: Use the global gradle configuration file. The steps are:

  1. Identify your gradle local path. It’s usually in:

    • C:\Users\<username>\.gradle (Windows)
    • ${HOME}/.gradle/ (Mac/Linux)

    It can also be custom set via GRADLE_USER_HOME

  2. Open (or create) in there.

  3. Add the environment specific configuration (e.g. proxy)

  4. Restart AS/gradle daemon…

  5. Enjoy!


Share on

A little experiment: