I\'m trying to rebuild my Android Studio Gradle project (containing mostly Kotlin code), but it started to throw an UnableToDeleteFileException
during the clean
Try File -> Invalidate Caches and Restart
This worked for me
I was facing same issue on Android Studio 2.2 preview 1, solution by @AndresSuarez was correct but for some reasons I couldn't find JAVA TM process in my task manager. So I tried the following solution and it worked -
Open command prompt and type TASKKILL /F /IM java.exe
. This will kill all JAVA TM processes automatically. Now re-compile the app again, it will work.
Additionally, you can create a .bat file, add the above code in it and run it every time you face the issue.
i simply run cmd command - > gradlew clean , And it fix the issue
I had the same issue after moving my project from D: to G: drive but disk checking solved my issue
I used chkdsk /f /r /x G: ** here some command line switches were used:**
/F Fixes errors on the disk
/R Locates bad sectors and recovers readable information (implies /F)
/X Forces the volume to dismount first if necessary (implies /F) (important)
Note: /X is important because it will dismount the drive and you can manually delete the build directory of your project,
now rebuild the project
As suggested in the bug report, uncommenting the line
idea.jars.nocopy=false
in the idea.properties
file has solved the issue for me.
Note that this needs to be done every time Android Studio updates.
For me, the culprit is adb holding onto the apk file since I utilise it to install and start the application on my physical device through command line.
So simply:
Task Manager > End process adb.exe
And then the file is free to be deleted and the project may be cleaned