After a long search, I finally found the cause and the solution.
Cause:
The problem was caused by an automatically mounted ntfs hard disk. I saved all my projects files in an ntfs partition, but Ubuntu recognized the ntfs partition as a removable device (e.g. USB).
Solution:
1. Run sudo umount <name of the drive (e.g. /dev/sda1)>
to unmount the drive in problem.
2. Run sudo cp /etc/fstab /etc/fstab.backup
to make a backup of fstab.
3. Open /etc/fstab with any text editor.
Here, find the line that specifies your ntfs partition.
The line should look like this:
UUID=<16 digit uuid> <something> ntfs defaults,umask=007,gid=46 0 0
Add errors=remount-ro,uid=1000
after defaults,umask=007,gid=46
So after the change, it will look like this:
UUID=<16 digit uuid> <something> ntfs defaults,umask=007,gid=46,errors=remount-ro,uid=1000 0 0
- Reboot your system
Now, gradle should not give the execution failed error anymore.