Tip: Use local Gradle distribution instead of wrapper

The very first thing, that I’m doing after project import into Android Studio, is the switch from Gradle wrapper to local Gradle distribution. That have two benefits:

  • All projects can use same Gradle daemon.
    When you switch project A to project B and they have different gradle wrapper versions, Android Studio has to start different daemons. This can happen when you switch between different branches on the same project. Less daemons started in same time — less pressure on the system.
  • Bump Gradle version independently from the project.
    It takes time until new version propagates everywhere. All projects, all branches. Some teams are very fast in that, some are more conservative. With local distribution you can bump Gradle the same day stable version is released or even use release candidate version. One command and new version is applied to all your projects.

How to install Gradle

On Mac: brew install gradle

On Windows: download, unpack and install

How to configure Android Studio

Image for post
Image for post

Open Preferences -> Build, Execution, Deployment -> Gradle. Select Use local gradle distribution and specify Gradle home.

On Mac: /usr/local/opt/gradle/libexec in case you installed it via brew.

For Windows: specify the path where you installed Gradle.

How to use from terminal

Just use gradle instead of ./gradlew. For example: gradle assembleDebug

How to see how many daemons are running

Execute gradle --status

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store