Stop every Gradle daemon so nothing holds the cache open.

Kill any leftover Java processes from a crashed IDE sync if the error persists after step 1.

Delete the metadata cache for your Gradle version.

Run the build again with a plain compile task first.

If the error returns on every run, check the disk and the antivirus or sync tool watching the Gradle home.