21

Today I updated my Android Studio to 2.0 and when I run my project is gives me this error

Error:Execution failed for task ':app:clean'.
> Unable to delete directory: /media/dev1/08782A6D782A5A281/workspace/gengold/GenGold/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/jars

This is my build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"
    defaultConfig {
        applicationId "com.mobile.gengold"
        minSdkVersion 15
        targetSdkVersion 21
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {

    compile 'com.android.support:support-v4:21.0.2'
    compile 'com.android.support:appcompat-v7:21.0.3'
        /*compile 'com.google.android.gms:play-services-maps:6.5.+'*/
    compile 'com.google.android.gms:play-services:6.5.87'
    compile files('libs/jncryptor-1.2.0.jar')
}

I have deleted the jars from that directory but it shows the error repeatedly. Also it creates the directory again.

Biswajit Karmakar
  • 9,799
  • 4
  • 39
  • 41
Akshat Vajpayee
  • 274
  • 1
  • 3
  • 15

16 Answers16

18

I have exactly the same problem. The only temporary solution I've found is to exit Android Studio, delete the entire "build" folder (not only the jars), and then getting back to Android Studio to Build it.

The first build goes without errors or any warnings, but to rebuild again you need to follow the same steps as before :(

This is not a solution, obviously, but seems like the problem comes out from any service keeping occupied the files to be deleted in the "Clean" part of the rebuilding process.

EDIT:

It seems there is a problem with NTFS file system in android 2.0 Check out in https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened&groupby=&sort=&id=206219

Salvador Moreno
  • 261
  • 2
  • 6
  • 1
    I tried that too but WIndows says I don't have permission to do that (even when I run Windows Explorer as administrator)... :s So typical, I guess I'll have to reboot into Linux and wipe the folder from here, that's my standard procedure when such things happen (it's sadly a bit common, although in Android Studio 1.5.1 it was very rare) – user14764 Apr 08 '16 at 21:03
  • 2
    I already posted the bug in https://code.google.com/p/android/issues/detail?id=206219 and it has been flagged as Critical. I hope the people at google fix it sooner or later. – Salvador Moreno Apr 09 '16 at 08:54
  • This is really a very non-sense bug we are facing in android studio 2.1 also. It seems like they are not really solving this. Because of this issue I am not just able to use it and still working on older versions. – Pravesh Jun 24 '16 at 05:50
  • I'm using Android Studio 2.1.3 and Windows 10. The issue is still here, straying in the darkness, crawling through your nightmares ... sometimes it spout with no particular reason, on a random file or directory under build. Processes are higgly piggly, and threads seems sometimes to not be synchronized, thus trying to access to used file. – Alex Oct 12 '16 at 07:43
  • AndroidStudio 2.2.2 and Fedora 23, problem still there. – Lieuwe Nov 18 '16 at 11:03
  • lol, I just did an explicit Build -> "Clean project" and it worked! Maybe it just needed a nudge from the UI side... Some Android Studio magic! xD – varun May 17 '19 at 09:52
  • I found that I had another build file somewhere in the project besides the one in the main directory (file for windows users) I searched for build and then deleted that directory as well. @user14764 I had to close the google back up app that was running in the background because it was using it and that's why I couldn't delete it make sure nothing is using the file or has the file open, that's also why a restart might be helpful – Chagai Friedlander May 26 '20 at 09:08
11

For me: Open the command prompt and type taskkill /F /IM java.exe. This will kill all java TM processes automatically.

10

I'm using Android Studio 2.3.3 on windows, had the same problem, tried deleting the folder and got Access denied, rebooting my computer did not help either, for me the solution was : In Android Studio > File > Invalidate Caches / Restart...

hmk
  • 139
  • 1
  • 5
6

i'm using android studio 2.0 and ubuntu 14.04 64bit.

i have the same problem, i just delete directory under ../app/build/intermediates/exploded-aar/com.android.support/

i delete all of this

it works, i can run my project, but it will be showed again in the next running.

4

For me, rebooting my computer unlocked the locked file and solved the problem.

FractalBob
  • 3,225
  • 4
  • 29
  • 40
3

I noticed this started happening after I installed Tortoise SVN. I think installing it using a non-admin Windows account, might be the root of the issue.

Unheilig
  • 16,196
  • 193
  • 68
  • 98
Dilleyboy
  • 41
  • 4
  • 3
    I don't know why my answer was edited, but now it reads as if I'm saying I installed it using a non-admin account, when I originally meant that I was using Android studio with a non-admin account. And I said I couldn't comment yet so I could clarify that I'm not sure this is the actual cause, but just something I noticed in hopes it might help someone else find the actual answer to the issue. – Dilleyboy Dec 02 '16 at 02:23
2

After weeks of searching, I've found out that my Cloud-Sync-programs (I am using Tresorit, but same would apply to Dropbox or Google Drive aso) locked the files that AndroidStudio was trying to delete while uploading them to the cloud storage - and therefore making it impossible for AndroidStudio to delete the files.

On some cloud storage programs, you may use path filters - simply exclude the "build"-directories from your cloud storage (you usually dont need them backupped either way), or pause your cloud sync while working on the project.

Martin Bories
  • 1,067
  • 17
  • 37
1

It states that Android Studio doesn't has the privilege to delete the directory.

Simply right on your project folder in windows explorer -> properties -> Security -> Edit -> here provide the necessary privilege like in my case added full control to my user that was logged in the Windows system.

Prajwal Waingankar
  • 2,534
  • 2
  • 13
  • 20
0

Try to make the usage of the “file smash” function from tencent qq pc manager. The manager can unlock the file and then delete it.

Where to use it? After you install QQ pc manager, choose tool kits and install "file smash" tool. And then choose the file to delete, press right key of mouse and you find the function to unlock file and delete it.

That works for me. I guess other pc manager like qq manager may have this function too. That's all.

0

I had the same problem. In my situation I install the android studio at D folder and copy paste the projects folder to the same folder of android instalation

Solution

Move your projects folder out of the android folder.

0

I was having the same problem and installed LockHunter and deleted the folder forcefully. None of the above solution worked for me so this is what I did.

TechieBoy101
  • 284
  • 1
  • 3
  • 16
0

There is a folder called mergdebugassets.

In our case,

  • Right click on it in File Explorer
  • Go to properties
  • untick Read Only
  • Apply.

This could solve the problem with whatever was the folder in your case.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Ali Borsan
  • 41
  • 3
0

In my case, the dependencies file was locked by Dropbox. Problem was solved after I stopped dropbox syncing service.

Eric Low
  • 11
  • 4
0

In my case, the problem was due to prohibited character (') in strings.xml. Once I deleted ('), this problem was solved.

0

Go app folder and delete build folder. After that go android studio and run. It should be fixed.

-2

I had same problem in Android Studio 3.6. I was unable to delete the build folder so I renamed it and it worked for me.

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140