For me, deleting the lock file worked, as suggested in the answer above:, rm /Users/xxx/.gradle/caches/4.1-rc-1/fileHashes/fileHashes.lockas well as killing IDLE processes with the command
./gradlew
It generates a list of Gradle processes with status like
PID STATUS INFO
23580 IDLE 5.2.1
23860 IDLE 5.2.1
19058 STOPPED (stop command received)
Then kill one of the idle processes with kill <PID>and run the gradle build again.
source
share