Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
Error:-

Failed to remove build. A program may still be using a file in the directory or the directory itself. To find and stop such a program, see:
https://superuser.com/questions/1333118/cant-delete-empty-folder-because-it-is-used
Solution:
This error occurs because a process (like your editor, emulator, or antivirus) is locking a file inside the build
directory, preventing flutter clean
from deleting it.
Hereโs how to fix it step-by-step:
1. Identify Whatโs Locking the File
Use Resource Monitor (built into Windows):
Step 1:- Press Ctrl + Shift + Esc
to open Task Manager.

Step 2:- Go to Performance โ Click Open Resource Monitor at the bottom.
Step 3:- In Resource Monitor, go to the CPU tab.

Step 4:- Use the Search Handle box (top right) and enter: classes.dex
or even just: dex

Step 5:- It will show you which process is using that file.
2. Kill the Locking Process
Once you find the process:
- Right-click the process in Resource Monitor โ End Process.
- If it’s your IDE (like Android Studio or VS Code), just close it completely, including background tasks like Gradle Daemon or ADB.
๐ 3. Retry flutter clean
Go back to your terminal:
flutter clean
Should work now.
Optional: Use Command Line Tool to Force Unlock
If you prefer using command-line tools, install Process Explorer from Microsoft:
- Run it as Administrator.
- Press
Ctrl + F
and search forclasses.dex
. - Right-click the locking process โ Kill Process.