I\'m using Gradle to build a java project. When I run any task (assemble, test). I get randomly an error :
Could not create service of type FileHasher using
What worked for me was removing the lock file like suggested in the answer above: rm /Users/xxx/.gradle/caches/4.1-rc-1/fileHashes/fileHashes.lock
and also killing the IDLE processes by running 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 by kill <PID>
and run the gradle build again.
This worked for me:
Turned off antivirus file protection
Invalidate caches/Restart
Run app
I was facing the same because I accidentally hit ctrl+z during build, and then the error was the same as yours.
I tried to remove the lock file but it didn't solve the problem.
Then I find all the process related to gradle by ps aux | grep gradle
, and then kill -9 <pid>
them all. The build backed to normal.
This was same problem for me before some days and now only it's your or the user reading this solution.
Uninstall full android studio (means- 'after uninstall from control panel, delete folders of Android Studio,') folders to be deleted:
C:\Program Files -> Android, C:\Users{user folder name} -> .android & .gradle & {other folders related to Android Studio}
Reinstall form it's .exe
and make sure your PC in connected with internet and with proper speed.
Download all SDK files as mention in that and keep downloading in Android Studio only. [do not download form other source- otherwise it will show errors, be careful]
Click on new project and select empty project and give the name and click on finish.
you will redirect to another window and than the main thing starts that is installation of GRADLE so for this you should have high connectivity of internet and that it will download automatically and and and now your are ready to go.
change the ownership of .gradle/
using the following command:
sudo chown -R <USERNAME> .gradle/
One simple cause is that gradle daemon is not started with the same environment variable. I had the same issue while changing the gradle user home.
Simply stop the daemon:
gradle --stop