Reputation: 15087
I noticed that the Gradle uses a separate daemon than the terminal does, and it uses the gradlew (wrapper) to run its own instance of Gradle daemon.
I noticed this when i tried to stop Gradle task in Android Studio by the command gradle --stop
. it says there is no daemon running. but when I use ./gradlew --stop
it stops the Gradle task. It's like I'm having two daemons running one for Android Studio and one for the terminal.
How can I make the Android Studio to use the same daemon that the terminal is using (when I start a Gradle task by gradle build
command, the terminal starts a daemon and uses it).
How can I do this?
Upvotes: 0
Views: 2048
Reputation: 79
It was a lot of work but I was able to find a better solution than using the local gradle distribution
Please have a look at my bug report where everything is explained and hopefully this will be solved by Google or Gradle in a future release
https://issuetracker.google.com/issues/68374709
Upvotes: -1
Reputation: 15087
I found the answer myself by testing many ways.
the point is when u use Gradle wrapper it will start a new daemon for every project even if they are with the same version you can stop using Gradle wrapper by one change in Android Studio so it uses system Gradle daemon (not using wrapper and running a new daemon for each project)
you need to go to "Settings ->Build, Execution, Deployment -> Build tools -> Gradle" then check the radio button "Use local Gradle distribution" and address the "Gradle Home" field to the system Gradle_Home installation.
though you need to have already Gradle installed on your system.
for me its directory is: "/home/[my_user]/.gradle/wrapper/dists/gradle-3.1-all/ejgglywf033yp6s4x8ahmgm74/gradle-3.1"
the good point about this is you will have just one instance of Gradle Daemon (starting daemons takes time - especially if you are working on multiple project at the same time like me), and the negative point is you will have to change the directory manually when you want to migrate to new Gradle version distributes.
I dont know why but with this method the Gradle syncs faster on my pc. let me know if its also faster in your computer.
Upvotes: 4