I\'m trying to rebuild my Android Studio Gradle project (containing mostly Kotlin code), but it started to throw an UnableToDeleteFileException
during the clean
I killed all the java TM processes in the task manager and it let me to rebuild
Clean project from Terminal using this command gradlew clean
.
I just solved this exact problem for myself.
The problem was that somebody else had created the file so even though I have admin rights on the computer I was unable to make changes to the file or files. You need to go into the properties of the file or folder and change the ownership or add ownership. This web page explains it well step by step what you need to do.
Once I did the above, I found the file in file explorer and manually extracted it. I don't think it's needed in the android studio project if it was trying to delete it anyway.
In Android Studio 3.0, I had the same issue. This fixed it:
I solved with command:
taskkill /F /IM java.exe
and then:
gradle assembleDebug
The solution is quite easy.
This is one of the solution which worked for me.
It might be possible that your project's app/build/outputs/apk folder is opened.
so just close this folder and rebuild your project. and it will be solved.