It is currently in use by another Gradle instance

2019-01-21 15:51发布

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.

16条回答
Viruses.
2楼-- · 2019-01-21 16:35

Its Work for me for Problem:-

"Error:Timeout waiting to lock jars It is currently in use by another Gradle instance. Owner PID: 6896 Our PID: 5048 Owner Operation: Our operation: Lock"

Solution:-

  1. close the Android Studio and Open Task manager and end the process java.exe
  2. open the derectory ....gradle\caches.
  3. Delete the jar2.lock file.
  4. Open android Studion and clean the project.
查看更多
Luminary・发光体
3楼-- · 2019-01-21 16:38

Very simple solution:

no need to kill Android Studio , just Kill OpenJdkPlatform process, then delete the .lock file located in:

rootProject/.gradle/<version>/taskHistory
查看更多
淡お忘
4楼-- · 2019-01-21 16:40

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?

查看更多
放荡不羁爱自由
5楼-- · 2019-01-21 16:42

For Windows machine:

Open Task Manager(Ctrl-Alt-Delete and check Process)

-> If you run two instance of android studio, Close One (End Task)

-> Then close OpenJDK Platform Binary

-> Gradle sync now on AndroidStudio and it will work now

查看更多
迷人小祖宗
6楼-- · 2019-01-21 16:42

I had same problem and i did two steps and it became solved.

  1. My JDK was not installed on Mac (i forgot to install) i installed it.
  2. I deleted all items from caches folder located in this path /Users/icon_developer/.gradle/ and rebuilt the project. It worked!
查看更多
小情绪 Triste *
7楼-- · 2019-01-21 16:44

It was not necessary for me to remove any files to fix this error.

The issue I had is that Gradle instances had hung and were 6 command prompt entries in my task list that were spawned by Java.

Forcing the command prompt instances to close allowed me to continue work as usual.

查看更多
登录 后发表回答