Gradle build is hanging without failure, DefaultFileLockManager acquiring and releasing lock on daemon addresses registry

☆樱花仙子☆ 提交于 2019-12-06 12:32:43

I had the same issue. In my case setting proxy in ~/gradle/gradle.properties helped:

systemProp.http.proxyHost=hostname
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=user
systemProp.http.proxyPassword=password

In order for gradle work properly, you need to configure at least 3 kind of proxies on Linux/macOS which are

  • gradle proxies - inside gradle.properties
  • maven proxies - inside ~/.m2/settings.xml
  • bash proxies - inside ~/.bashrc or ~/.bash_profile

Apart from these proxy settings, you also need to double check your proxy settings of your OS, e.g. on mac, check "System Preferences" -> "Network" -> "Advanced..." -> "Proxies". You may need try to turn on/off this system proxies.

However, sometimes, like your case, it may not because of connectivity problems, but due to permission issues. If you ever ran your gradle commands using "sudo" then some of the directories generated during executing the gradle commands may become owned by "root". Hence, when you try to run gralde commands using normal user, these directories are not accessible. The bad thing is that gradle does not give you any information or even hints to "permission".

The solution to this is as below.

  • To find all the files and directories that are owned by root or belong to root group:

    $ls -alR | grep -w root > list.txt

The result of this command will be output to file list.txt, open it to check all the files and directories. For example you may see the output something as below:

drwxrwxr-x+ 86 root  admin   2.9K Jun 29 20:30 Applications/
drwxr-xr-x+ 65 root  wheel   2.2K May 19 00:19 ***/.gradle
drwxr-xr-x@  2 root  wheel    68B Nov 20  2016 ***/build
drwxr-xr-x@  4 root  wheel   136B Jun 29 20:31 .gradle
drwxr-xr-x    3 employee  staff   102B Nov 10  2015 Samsung/
drwxr-xr-x    7 employee  staff   238B Jul  6  2016 VirtualBox VMs/
drwxr-xr-x    3 employee  staff   102B Nov  4  2016 android-ndk/
drwxr-xr-x    3 employee  staff   102B Aug 31  2016 bin/
  • To find the exact location of those files or directories

    $find "$PWD" | grep your-file-name

  • Delete those files or directories.

    $ sudo rm -rf your-file-name

Usually, you need change your directory to below locations to perform above actions to delete all the files with root user.

  • ~/.gradle – The .gradle cache under your user’s “Home” directory
  • /.gradle – The .gradle cache under your project root directory
  • [project-root]/[module]/build – The .gradle cache under your gradle module directory.
  • ~/.m2 – The Maven cache directory under your user’s “Home” directory

Then start over a gradle sync, the problem should be resolved.


You can find more detailed descriptions from below blogs:

  1. gradle-sync-issue-on-debian-os-due-to-user-does-not-have-permission
  2. android-gradle-plugin-3-0-sync-issue
  3. gradle-proxy-configuration
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!