I have browsed several topics surrounding this subject but none are quite recent and maybe someone else can help me. If I clean my project or even try to rebuild it a continuously get an error that says
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:clean'.
> Unable to delete directory 'K:\Android\DementiaApp\app\build'
Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory.
- K:\Android\DementiaApp\app\build\intermediates\transforms\dexBuilder\debug\0\com\example\seansandroid\myApp\Games
- K:\Android\DementiaApp\app\build\intermediates\transforms\dexBuilder\debug\0\com\example\seansandroid\myApp
- K:\Android\DementiaApp\app\build\intermediates\transforms\dexBuilder\debug\0\com\example\seansandroid
- K:\Android\DementiaApp\app\build\intermediates\transforms\dexBuilder\debug\0\com\example
- K:\Android\DementiaApp\app\build\intermediates\transforms\dexBuilder\debug\0\com
- K:\Android\DementiaApp\app\build\intermediates\transforms\dexBuilder\debug\0
- K:\Android\DementiaApp\app\build\intermediates\transforms\dexBuilder\debug
- K:\Android\DementiaApp\app\build\intermediates\transforms\dexBuilder
- K:\Android\DementiaApp\app\build\intermediates\transforms
- K:\Android\DementiaApp\app\build\intermediates
The file in question is the intermediates. I have seen a lot of people say that you just need to delete this file. For some reason, even if I try to delete the intermediates, they just wont delete! Can anyone help me? This is really annoying.
I'll post the solution to my own question because its worked for me and may help others in the future.
No matter what, my file would not allow me to delete it, regardless of administrative privileges.
By renaming the file, Android Studio identified the file as 'missing' and regenerated another build file. This then allowed me to rebuild and clean my project.
It now works again!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With