Set Different Gradle Configurations

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!


A little experiment: If you find this post and ad below useful, please check the ad out :-)

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.