Gradle :Could not create service of type FileHasher

前端 未结 11 935
南方客
南方客 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:30

    If the OS is Windows. Try this: gradlew build Find de PID Process

    And in CMD execute this command

    TASKKILL /F /PID  #PID
    
    0 讨论(0)
  • 2020-12-14 07:30

    I just moved a project from Download folder (on Mac) to another one

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

    In your terminal type this:

    ./gradlew build
    

    and the outcome would 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
    

    and build again.

    P.S replace xxx with whatever username you've.

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

    I couldn't find this info elsewhere, posting in case it helps someone:

    I had the same issue while running Android Studio on ChromeOS (on Chromebook).

    I had shared a Google Drive folder with Linux (by selecting a folder, right-clicking and selecting Share with Linux) and created my project there. Build failed with this error, and removing the lock file did nothing for me.

    Problem was resolved for me by re-creating the project under a 'Linux folder'.

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

    I had the same issue and the solution was to login with the correct user and then run gradle. I was logged in with a user that didn't had rights to run the tasks.

    0 讨论(0)
提交回复
热议问题