Gradle :Could not create service of type FileHasher

前端 未结 11 934
南方客
南方客 2020-12-14 06:44

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         


        
相关标签:
11条回答
  • 2020-12-14 07:13

    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.

    0 讨论(0)
  • 2020-12-14 07:16

    This worked for me:

    1. Turned off antivirus file protection

    2. Invalidate caches/Restart

    3. Run app

    0 讨论(0)
  • 2020-12-14 07:26

    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.

    0 讨论(0)
  • 2020-12-14 07:26

    This was same problem for me before some days and now only it's your or the user reading this solution.

    1. 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}

    2. Reinstall form it's .exe and make sure your PC in connected with internet and with proper speed.

    3. 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]

    4. 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.

    0 讨论(0)
  • 2020-12-14 07:28

    change the ownership of .gradle/ using the following command:

    sudo chown -R <USERNAME> .gradle/ 
    
    0 讨论(0)
  • 2020-12-14 07:29

    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
    
    0 讨论(0)
提交回复
热议问题