Tip: How to reuse Gradle daemon between Android Studio and terminal

When I run first gradle command from terminal, it starts new daemon instead of reusing already existed one.

Starting a Gradle Daemon, 1 incompatible and 0 stopped Daemons could not be reused, use — status for details

That’s strange, because Android Studio already started one daemon and I want to reuse it.

Why I want to reuse existing daemon

  • It consumes additional memory

Why daemon from Android Studio is not compatible for terminal

How to make daemon compatible

Set JDK location in Project Structure

On Mac you can easily find JDK location by executing

echo $(/usr/libexec/java_home)

How to see how many daemons are running

PS. This applies to Gradle wrapper and locally installed Gradle. I recommend to use local Gradle distribution. See my previous Tip to find out why.