我想做一些基本的函数。我正在命令行中运行/构建它。我在看用户指南。还有,做一些简单的任务。
当我开始运行简单的任务时,它被成功构建。但是,在一段时间后,它会显示“它目前正在被另一个Gradle实例使用”,并变成BUILD FAILED。我正在使用终端运行任务。那时候我什么都没做。
如果我关闭产生错误的终端,这个问题就解决了。但是,我知道这不是解决办法。
为什么这个错误经常出现?
如何解决?
并且,请参考任何链接来提高我对Android中Gradle Build系统的知识。
我想做一些基本的函数。我正在命令行中运行/构建它。我在看用户指南。还有,做一些简单的任务。
当我开始运行简单的任务时,它被成功构建。但是,在一段时间后,它会显示“它目前正在被另一个Gradle实例使用”,并变成BUILD FAILED。我正在使用终端运行任务。那时候我什么都没做。
如果我关闭产生错误的终端,这个问题就解决了。但是,我知道这不是解决办法。
为什么这个错误经常出现?
如何解决?
并且,请参考任何链接来提高我对Android中Gradle Build系统的知识。
当前回答
Windows用户:
Gradle失败消息后面通常跟着相关的进程id,所以应该是这样 Gradle同步失败:超时等待锁定守护进程地址注册表[…] 它目前正在被另一个Gradle实例使用。
Owner PID: 8080
Our PID: 89765
Owner Operation: ...
In order to unlock, just kill the owner process:
taskkill /PID 8080 /F
taskkill /PID 89765 /F
其他回答
我没有必要删除任何文件来修复这个错误。
我遇到的问题是Gradle实例挂起了,并且在我的任务列表中有6个命令提示项,这些命令提示项是由Java生成的。
强制关闭命令提示符实例允许我像往常一样继续工作。
每个人最后, 我有完整的解决方案
Error :- Timeout Gradle cashe its running in other gradle
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Please add this Line in Wrapper.Propertis and Sync now
After Sync the project When
Invalidthcast\restart to get the requesting componants
Gradle失败消息后面通常跟着相关的进程id,所以应该是这样
Gradle sync failed: Timeout waiting to lock daemon addresses registry [...].
It is currently in use by another Gradle instance.
Owner PID: 1234
Our PID: 5678
Owner Operation: ...
为了解锁,只需杀死所有者进程:
sudo kill -9 1234
在@Sean Stayns的回答中引用了一个场景,以防它能帮助到任何人:如果你把你的项目保存在谷歌Drive文件夹中——不要这样做。只需将项目移动到本地驱动器即可解决此问题。
In the case we were trying to solve, were were also getting the "It is currently in use by another Gradle instance" error and nothing we tried here worked. The process ID was unknown as well. It didn't immediately occur to me to ask where the project was being saved, so in case anyone new to Android Dev is saving their projects to a Google Drive folder, just move over to your local drive. I would have just left this as a comment in @Sean Stayns's answer, but I can't comment. Hopefully it benefits someone.
有时,您需要在每次构建错误后运行此代码几次
对我来说,它需要两次,首先我得到锁定错误,我运行这段代码,然后我再次得到另一个文件的锁定错误,所以我再次运行代码,在结束时它正常工作。
find ~/.gradle -type f -name "*.lock" -delete