- Stops Gradle daemons
- Clears
~/.gradle/caches/x.x.0 - Clears
~/.gradle/caches/jars-9 - Clears
~/.gradle/wrapper/dists/gradle-x.x.0-bin(unless you opt out) - Optionally runs
.\gradlew.bat helpto verify after cleanup
Step 1 — Kill all Gradle daemons first (they hold the file lock)
Powershell
.\gradlew.bat --stop
# Wait 5 seconds to ensure processes exit
Start-Sleep -Seconds 5
# Belt-and-suspenders: kill any surviving Java daemon processes
Get-Process -Name "java" -ErrorAction SilentlyContinue | Stop-Process -ForceShellscript
.\gradlew --stop
# Wait 5 seconds to ensure processes exit, and then run the command below to find any "java" process alive
ps -aux | grep "java"Step 2 — Manually delete the journal
Powershell
Remove-Item "$env:USERPROFILE\.gradle\caches\journal-1" -Recurse -ForceShellscript
rm -rf "$HOME\.gradle\caches\journal-1".\reset-gradle-cache.ps1Safe preview first (recommended)
.\reset-gradle-cache.ps1 -DryRun -SkipGradleRunUseful options
# Keep downloaded Gradle distribution zip/unpacked folder
.\reset-gradle-cache.ps1 -KeepWrapperDist
# Also clear configuration cache
.\reset-gradle-cache.ps1 -ClearConfigCache
# Use a custom repo path
.\reset-gradle-cache.ps1 -ProjectPath "C:\path\to\repo"
Next time Gradle sync breaks, just run this from the repo root:
.\fix-gradle-sync.ps1It automatically runs the full reset including the configuration cache (which is the most common culprit for Kotlin DSL compilation breakage). Any extra flags you pass are forwarded — e.g.:
# Preview what it will do without touching anything
.\fix-gradle-sync.ps1 -DryRun
# Skip the verify-run at the end if you want to do it manually
.\fix-gradle-sync.ps1 -SkipGradleRun