Stack Overflow archive
18 score

How can I force Gradle to redownload dependencies?

score
18
question views
1.2M
license
CC BY-SA 3.0

Instead of removing your entire gradle cache, like some answers here are suggesting, you can delete the cache for a specific group or artifact id. I added the following function to my .bash_profile:

bash
deleteGradleCache() {
  local id=$1
  if [ -z "$id" ]; then
    echo "Please provide an group or artifact id to delete"
    return 1
  fi
  find ~/.gradle/caches/ -type d -name "$id" -prune -exec rm -rf "{}" \; -print
}

Usage:

text
$ deleteGradleCache com.android.support

Then, on the next build or if you resync, gradle will re-download dependencies.

Originally posted on Stack Overflow. Public user contributions are licensed under Creative Commons Attribution-ShareAlike.