# 清理 Gradle 缓存和项目构建目录 Write-Host "开始清理..." -ForegroundColor Green # 清理项目 build 目录 Write-Host "清理项目 build 目录..." -ForegroundColor Yellow if (Test-Path ".\build") { Remove-Item -Path ".\build" -Recurse -Force Write-Host "已清理 build 目录" -ForegroundColor Green } # 清理 app build 目录 Write-Host "清理 app build 目录..." -ForegroundColor Yellow if (Test-Path ".\app\build") { Remove-Item -Path ".\app\build" -Recurse -Force Write-Host "已清理 app build 目录" -ForegroundColor Green } # 清理有问题的 Gradle 缓存 Write-Host "清理 Gradle 缓存..." -ForegroundColor Yellow $gradleCachePath = "C:\Users\lee\.gradle\caches\8.13" if (Test-Path $gradleCachePath) { # 清理 groovy-dsl 缓存 $groovyDslPath = Join-Path $gradleCachePath "groovy-dsl\070ba2b51e09fa9c0e770e7c757cc8a3" if (Test-Path $groovyDslPath) { Remove-Item -Path $groovyDslPath -Recurse -Force -ErrorAction SilentlyContinue Write-Host "已清理 groovy-dsl 缓存" -ForegroundColor Green } # 清理 transforms 缓存 $transformsPath = Join-Path $gradleCachePath "transforms\44e7089f2786c22da3ed6c59f9f06cc8" if (Test-Path $transformsPath) { Remove-Item -Path $transformsPath -Recurse -Force -ErrorAction SilentlyContinue Write-Host "已清理 transforms 缓存" -ForegroundColor Green } } Write-Host "`n清理完成!" -ForegroundColor Green Write-Host "`n现在开始构建..." -ForegroundColor Yellow # 执行构建 .\gradlew.bat clean assembleRelease --no-daemon --refresh-dependencies Write-Host "`n构建完成!" -ForegroundColor Green Write-Host "APK 文件位置:app\build\outputs\apk\release\app-release-unsigned.apk" -ForegroundColor Cyan