清理安装失败的模拟器,只需"三删"即可彻底释放空间:
- 删配置:进入
C:\Users\用户名\.android\avd,删除以模拟器名称命名的.avd文件夹和.ini文件。(即你截图中的内容) - 删镜像:进入 Android SDK 的安装目录,删除
system-images文件夹下的所有内容(这是最占空间的部分,通常有 2-5GB)。 - 删残留:进入
%TEMP%文件夹,删除所有以android开头或.zip结尾的临时文件。
建议:清理后,请将工具整个移至 D 盘运行,避免 C 盘再次爆满。
# --- Android CLI 失败安装清理脚本 ---
Write-Host "正在开始清理 Android 残留文件,请稍候..." -ForegroundColor Cyan
# 1. 清理 AVD 配置文件 (C 盘用户目录)
$avdPath = "$env:USERPROFILE\.android\avd"
if (Test-Path $avdPath) {
Write-Host "正在清理 AVD 配置文件: $avdPath" -ForegroundColor Yellow
Remove-Item -Recurse -Force "$avdPath\*" -ErrorAction SilentlyContinue
}
# 2. 清理系统临时文件夹中的残留压缩包
Write-Host "正在清理系统临时垃圾..." -ForegroundColor Yellow
Get-ChildItem -Path $env:TEMP -Filter "*android*" | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
Get-ChildItem -Path $env:TEMP -Filter "*.zip" | Where-Object { $_.Length -gt 100MB } | Remove-Item -Force -ErrorAction SilentlyContinue
# 3. 清理当前目录下的系统镜像 (假设你在 Android CLI 目录下运行)
if (Test-Path ".\sdk\system-images") {
Write-Host "正在清理当前目录下的 SDK 镜像..." -ForegroundColor Yellow
Remove-Item -Recurse -Force ".\sdk\system-images" -ErrorAction SilentlyContinue
}
# 4. 清理当前目录下的临时解压文件
if (Test-Path ".\temp") {
Remove-Item -Recurse -Force ".\temp" -ErrorAction SilentlyContinue
}
Write-Host "--- 清理完成!你的 C 盘已得到释放 ---" -ForegroundColor Green
Write-Host "建议:现在将整个文件夹剪切到 D 盘再重新开始。" -ForegroundColor White
pause