It is currently in use by another Gradle instance

I'm new to Gradle build system. I want to do some basic functions on it. I'm running/building it in command line. I am referring User guide. And, doing some simple tasks.

When I start to run simple tasks, it was build successfully. But, After some times, it is showing "It is currently in use by another Gradle instance" and becomes BUILD FAILED. I'm using a terminal for run the task. I didn't run anything at that time.

If I closed the terminal which generate the error, this problem would be solved. But, I know that it is not the solution for that.

Why is this error coming frequently?

How to solve it?

And, Please refer any link to improve my knowledge on Gradle Build system in Android.


Remove the lock files in the gradle cache by executing something like this:

find ~/.gradle -type f -name "*.lock" -delete

Sometimes fast way comes in a non-elegant deal, there we go:

Find first the # of all gradle process running on

ps -A | grep gradle

After that, get the IDs, Kill 'em all one by one

sudo kill -9 <process ID>

Now you're good ;-)


I was stuck with this error and had to blow away the contents of my user's .gradle/caches/ folder and the contents of my project's .gradle/ folder to get going again.

Not sure what caused it, possibly a failed build that kept these files in a locked state?