Android Studio中无法删除损坏AVD及锁文件,求解决方案
Yep, I’ve run into this exact frustrating issue before—those lingering QEMU processes and un-deletable lock files are a real headache when you’re trying to clean up a broken AVD. Here’s a step-by-step solution that’s worked for me and other Android devs:
Step 1: Force Kill the QEMU Process
The error says multiinstance.lock is open by qemu-system-x86_64, so we need to shut that process down first:
- Using Task Manager: Press
Ctrl+Shift+Escto open Task Manager, switch to the Details tab, find every instance ofqemu-system-x86_64.exe, right-click each one, and select End Task. Make sure you get all of them—sometimes multiple processes stick around. - Using Command Prompt (Admin): Open Command Prompt as an administrator, then run this command to force-kill all QEMU processes at once:
Thetaskkill /f /im qemu-system-x86_64.exe/fflag forces termination, and/imtargets the process name.
Step 2: Delete Lock Files & Directories
Once the QEMU processes are gone, head back to the AVD’s directory: C:\Users\asdfg.android\avd/Pixel_2_API_29_-_AC5.avd/
- First, delete the
multiinstance.lockfile—this should now work without the "in use" error. - Next, delete the
hardware-qemu.ini.lockdirectory. If the system says the folder is still in use, check inside it for any leftover files and delete those first, then delete the empty directory.
Step 3: Delete the AVD via Android Studio
Go back to Android Studio’s AVD Manager, select the broken Pixel_2_API_29_-_AC5 AVD, and try deleting it again. It should now go through without the "still running" error.
Alternative Workarounds (If Steps 1-3 Fail)
- Manual AVD Cleanup: If the AVD Manager still won’t delete the AVD, you can manually remove all its files:
- Navigate to
C:\Users\asdfg.android\avd/ - Delete both the
Pixel_2_API_29_-_AC5.avdfolder and thePixel_2_API_29_-_AC5.inifile. This completely removes the AVD from your system.
- Navigate to
- Restart Your Computer: As a last resort, restarting your PC will terminate all lingering processes automatically. Once your system boots back up, you’ll be able to delete the lock files and the AVD without issues.
Quick Tip for Future Issues
If your AVD crashes again, always check Task Manager first for leftover qemu-system-x86_64.exe processes—killing them right away can prevent these stubborn lock files from being created in the first place.
内容的提问来源于stack exchange,提问作者random512

