Error: Execution failed for task ':app:clean'. Unable to delete file

后端 未结 30 1181
感动是毒
感动是毒 2020-11-29 17:19

I\'m trying to rebuild my Android Studio Gradle project (containing mostly Kotlin code), but it started to throw an UnableToDeleteFileException during the clean

相关标签:
30条回答
  • 2020-11-29 18:05

    Try File -> Invalidate Caches and Restart

    This worked for me

    0 讨论(0)
  • 2020-11-29 18:05

    I was facing same issue on Android Studio 2.2 preview 1, solution by @AndresSuarez was correct but for some reasons I couldn't find JAVA TM process in my task manager. So I tried the following solution and it worked -

    Open command prompt and type TASKKILL /F /IM java.exe. This will kill all JAVA TM processes automatically. Now re-compile the app again, it will work.

    Additionally, you can create a .bat file, add the above code in it and run it every time you face the issue.

    0 讨论(0)
  • 2020-11-29 18:05

    i simply run cmd command - > gradlew clean , And it fix the issue

    0 讨论(0)
  • I had the same issue after moving my project from D: to G: drive but disk checking solved my issue

    I used chkdsk /f /r /x G: ** here some command line switches were used:**

    /F Fixes errors on the disk

    /R Locates bad sectors and recovers readable information (implies /F)

    /X Forces the volume to dismount first if necessary (implies /F) (important)

    Note: /X is important because it will dismount the drive and you can manually delete the build directory of your project,

    now rebuild the project

    0 讨论(0)
  • 2020-11-29 18:10

    As suggested in the bug report, uncommenting the line

    idea.jars.nocopy=false
    

    in the idea.properties file has solved the issue for me.

    Note that this needs to be done every time Android Studio updates.

    0 讨论(0)
  • For me, the culprit is adb holding onto the apk file since I utilise it to install and start the application on my physical device through command line.

    So simply:

    Task Manager > End process adb.exe

    And then the file is free to be deleted and the project may be cleaned

    0 讨论(0)
提交回复
热议问题