Gradle: Failed to create a service of type FileHasher

I am using Gradle to create a java project. When I run any task (collect, test). I get a random error:

Could not create service of type FileHasher using 
GradleUserHomeScopeServices.createCachingFileHasher()

Did anyone have the same problem before?

Gradle V: 3.5

java 8

I am using java plugin.

Thanks,

+15
source share
4 answers

I came across the same one because I accidentally pressed Ctrl + Z during the build, and then the error was the same as yours.

I tried to delete the lock file, but this did not solve the problem.

Then I find the whole process related to gradle using ps aux | grep gradleand then kill -9 <pid>all of them. The assembly returned to normal.

+19
source

In your terminal, enter this:

./gradlew build

and the result will be:

FAILURE: Build failed with an exception.

* What went wrong:
Could not create service of type FileHasher using GradleUserHomeScopeServices.createCachingFileHasher().
> Timeout waiting to lock file hash cache (/Users/zra/.gradle/caches/4.1-rc-1/fileHashes). It is currently in use by another Gradle instance.
  Owner PID: 17571
  Our PID: 26055
  Owner Operation: 
  Our operation: 
  Lock file: /Users/xxx/.gradle/caches/4.1-rc-1/fileHashes/fileHashes.lock

now do:

rm /Users/xxx/.gradle/caches/4.1-rc-1/fileHashes/fileHashes.lock

.

P.S xxx , .

+18

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 --status

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.

+1
source

This worked for me:

  1. Disable antivirus file protection

  2. Invalid Caches / Restart

  3. Launch the application

0
source

All Articles