Question

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 project I get something like below.

:app:clean FAILED Error:Execution failed for task ':app:clean'.

Unable to delete file: /media/DriveA/AndroidStudioWorkspace/DNA/app/build/intermediates/classes/debug/.../mechandising/MerchandizingActivity$3.class

When I try to delete the build folder manually I get the following error.

Error when getting information for file '/media/DriveA/AndroidStudioWorkspace/DNA/app/build/intermediates/pre-dexed': Input/output error

I am unable to figure out whether its a Linux problem or a Studio problem. I don't face such a problem in Eclipse (Same Drive) so I am just considering it to be something wrong with my studio.

Any Suggestions??

Was it helpful?

Solution

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.

OTHER TIPS

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

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.

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.

Clean project from Android Studio Terminal using this command 'gradlew clean'.

enter image description here

On Linux this could happen if you have a locked directories that prevents Android Studio from Deleting files.

you can run the Following command on Terminal:

sudo chown -R $USER: $HOME

Then try to rebuild --> Works for me

I had the same issue as you. I tried some of the solutions proposed on this page and it didn't work. So I used Process Explorer to find which process is locking the apk file and it was firefox. I think it keeps the file locked when I upload the apk in google play console. To make that go to "Find > Find Handle or DLL... > path-to-your-app.apk". Hope it help

I stopped the windows defender it was locking the file because it was need to scan , and the problem resolved

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 had a similar problem, when I was trying to debug my first android app. If you are running Android Studio on windows, I just restarted the Android studio and I did run Android Studio as Administrator which fixed the issue.

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.

I'm not on Windows, but OS X. Somehow my build folder didn't have the proper permission for AS to delete the file so I did chmod -R 777 <your_directory> in the affected parent directory.. probably 777 isn't what you would want but it worked for me.

Thanks to Gal's answer (https://stackoverflow.com/a/39904628/2870404).

In windows, using Windows file explorer,

  1. right-click on the directory,
  2. click properties on the context menu that will appear,
  3. then uncheck the "Read Only" attribute.
  4. After that, click the "Apply" to apply changes.

This fixed my problem.

Thanks to Gal's answer (https://stackoverflow.com/a/39904628/2870404).

In windows, using Windows file explorer,

right-click on the directory, click properties on the context menu that will appear, then uncheck the "Read Only" attribute. After that, click the "Apply" to apply changes.

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.

none of above answers didn't work for me, but change permistion works:

chown user:staff ../project_dir
find ../project_dir -type d -exec chmod 775 {} \;
find ../project_dir -type f -exec chmod 664 {} \;

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 came to this thread because I was having issues with my /release/app.aab getting locked. This prevented me from completing a project clean and generating a signed bundle. My work around was to restart my computer to get permissions back until I solved the issue.

It turns out that Git was locking the app.aab, and all I had to do was add "/release" to my /app/.gitignore.

Hope this helps someone.

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

2) Restart your android studio

Running android studio as administrator in windows worked for me. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top