Unable to clean project in Android Studio

Just ran into the same issue now - I accidentally edited one of the generated files and wanted to rebuild the app, but both clean and build failed due to some files being locked.

Luckily, I got cygwin on my Windows machine, so ls -l <file that studio complained about> revealed that these files were owned by some Administrator dude.

My first thought was that these files might had been created while Studio was running with admin privileges (I do this when I need to fetch updates from SDK manager). The idea was to try and resolve this issue by executing clean in Studio running with admin privileges, and later rebuild with normal privileges. Nope, this did not work :(

I decided to go for the brute force: sudo rm -rf app/build/* (in Cygwin this command looks a bit different: cygstart --action=runas rm -rf app/build/*). This resolved the issue and I was able to rebuild the project in Android Studio.


You can go into the project directory and call gradle from the command-line to do a clean on the project:

gradlew clean

When you reopen the project you will need to run a gradle sync again.


Go to

File > Settings > Build, Execution, Deployment > Instant Run > Uncheck this Check box (Enable Instant Run to hot swap code)

Thanks Have a nice coding


I had the same problem.

You need to go to the source file directly. Close the studio and go to the path the issue is located at and delete the folder there.