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

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


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

  • gradle proxies - inside
  • 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
[email protected]  2 root  wheel    68B Nov 20  2016 ***/build
[email protected]  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