Unable to delete directory in Android Studio

2019-03-12 17:15发布

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.

7条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-03-12 17:29

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.

查看更多
Luminary・发光体
3楼-- · 2019-03-12 17:32

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.

查看更多
混吃等死
4楼-- · 2019-03-12 17:36

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...

查看更多
叛逆
5楼-- · 2019-03-12 17:44

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

查看更多
Fickle 薄情
6楼-- · 2019-03-12 17:44

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.

查看更多
等我变得足够好
7楼-- · 2019-03-12 17:45

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.

查看更多
登录 后发表回答