OS version: Ubuntu 14.04 LTE 64 Bit
Java JRE/JDK version: Oracle JDK 1.8.0_11
Project directory is on a NTFS based drive.
Whenever I try to clean my
It should be a process lock the file handle. You can try to open your task manager to kill the process. In my case, the process is one of the Java process hold by Android Studio OpenJDK. Just find it and kill it.
I had the same problem. To build the project again and again I had to delete the build folder each time. The problem for me was an anonymous program called ByteFence.exe running in my system. When I uninstalled that program my issue was solved.
I stopped the windows defender it was locking the file because it was need to scan , and the problem resolved
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.
Go to your projects directory in the terminal and run gradlew clean
To run a Gradle command in your terminal/command prompt. Navigate to the root of your project and type gradlew
in the terminal or gradlew.bat
for the command prompt (windows users), followed by the command you would like to execute.
For a list of all possible gradle commands type gradlew tasks
into your terminal.
I solved this issue by closing android studio -> remove android platform via cli and then -> add the android platform again -> open project in android studio.