Gradle daemon keeps locking intermediate files, preventing builds

I’m on Windows 10. The Gradle Daemon keeps locking output files in the “intermediates” folder, for instance “classes.jar” preventint itself from overwriting it on build #2 and forward.

The error message I get (Norwegian first, Googled probable translation):

> java.nio.file.FileSystemException: C:\repos\myproject\mylib\build\intermediates\runtime_library_classes_jar\qaTermDebug\classes.jar: Prosessen får ikke tilgang til filen fordi den brukes av en annen prosess.

Probable english translation:
The process cannot access the file because it is being used by another process

Only solution is to run with deamon mode disabled or kill the daemon in between each build - something I obviously would like to avoid. Anyone else experiencing this?

Stuff I’ve tried:

  • Gradle v6.5
  • Gradle v6.4.1
  • Gradle v6.7
  • Oracle Java 8
  • Open JDK Java 11
  • Disabling parallell build
  • Build from Android Studio with bundled JRE
  • Build from command line with above-mentioned java versions

The only thing that “fixes” it is killing the gradle daemon.

It does not happen on trivial projects, only a larger project I have where the change has to be in the library module. Changing the app module works fine.

Suggestions?

Turns out it was a badly implemented plugin from AppDynamics that kept the lock . Bug reported to AppDynamics.

If you experience similar issues in your build pipline, look for custom build tasks that might misbehave.