82

I am trying to build one of my android libraries and everytime I get the following:

> Task :app:mergeDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Multiple build operations failed.
      java.nio.file.NoSuchFileException: /Users/user/.gradle/caches/transforms-3/0d92c5dbe3682b4fd3af323bb8f4fc81/results.bin
      java.nio.file.NoSuchFileException: /Users/user/.gradle/caches/transforms-3/c9e81cc37c2c0c47883b955549c67149/results.bin
      java.nio.file.NoSuchFileException: /Users/user/.gradle/caches/transforms-3/a60e256c2ccb687ca2c3dc1173bab875/results.bin
      java.nio.file.NoSuchFileException: /Users/user/.gradle/caches/transforms-3/a31caec1a4d16ac05a41b0f552f96191/results.bin
      java.nio.file.NoSuchFileException: /Users/user/.gradle/caches/transforms-3/9d3aed6b3e5d40e0d4373af6f3e198dc/results.bin
      java.nio.file.NoSuchFileException: /Users/user/.gradle/caches/transforms-3/f9c01a9d9c0a59b69c3974ffcd3c9cee/results.bin
      java.nio.file.NoSuchFileException: /Users/user/.gradle/caches/transforms-3/4d9724e0450bfaa483db25a04db0eb48/results.bin
      java.nio.file.NoSuchFileException: /Users/user/.gradle/caches/transforms-3/a79286d8497b8365dabe35ac25780fe4/results.bin
      java.nio.file.NoSuchFileException: /Users/user/.gradle/caches/transforms-3/2896cf3b957b3724a2dcfcee68be211f/results.bin
      java.nio.file.NoSuchFileException: /Users/user/.gradle/caches/transforms-3/2896cf3b957b3724a2dcfcee68be211f/results.bin

with about 200 more lines of the same

I've tried Invalidate Cache and Restart from android studio and I've tried rm -rf ~/.gradle/caches but I continue getting the same error. I am able to build the exact same library on my other computers - I just can't get it to work on one machine in particular. Is there any other thing I might be missing that could cause this?

4 Answers 4

146

Okay so I finally managed to get it to work...

Had to run rm -rf ~/.gradle instead of just rm -rf ~/.gradle/caches which I guess forced it to reinstall all the gradle things and then the build worked

6
  • thanks for sharing this, got the same issue and deleting ~/.gradle works for me this solution valid in 02/2022
    – Sam
    Commented Feb 17, 2022 at 2:11
  • This was really helpful! I was always going for ~/.gradle/caches folder. Then it would complain :/ Commented Aug 8, 2022 at 19:33
  • rm -rf ~/.gradle/caches doesn't help but rm -rf ~/.gradle does
    – Mia
    Commented Nov 29, 2022 at 5:55
  • 3
    I would first check the below answers. They are less invasive. And make sure that you save your ~/.gradle/gradle.properties if you have
    – velop
    Commented May 26, 2023 at 16:33
  • I had tried everything else other than rm -rf ~/.gradle and it did not work. So spare yourselves the time, remove ~/.gradle and get yourself a coffee instead.
    – Liviu Ilea
    Commented Apr 18 at 7:02
50

There's no need to delete the whole ~/.gradle directory. Killing the Gradle daemon before clearing ~/.gradle/caches worked for me.

You can kill the Gradle daemon using ./gradlew --stop.

0
3

Better to use:

macOS, Linux, or WSL:

./gradlew cleanBuildCache

Windows:

gradlew cleanBuildCache
3
  • 4
    this didn't work for me
    – reutsey
    Commented Feb 21, 2023 at 18:24
  • 11
    > Task 'cleanBuildCache' not found in root project Commented Jul 12, 2023 at 21:22
  • 2
    „The Android Gradle plugin's build cache has been deprecated. It will be removed in version 7.0 of the Android Gradle plugin.“ — not really a solution.
    – Martin
    Commented Nov 6, 2023 at 16:11
0

I could fix this error by deleting .gradle\caches\transforms-4 folder then syncing and rebuilding the project

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.