Android Studio: Change the Cache Location

Posted by in IT

Note: This is an updated article to reflect the stable release of AS. If you are looking for the old one, please see here.

Android Studio (AS) creates a local directory .AndroidStudio to cache its own data. In most environments, this is acceptable. However, the size of the directory can easily exceed 300Mb and, if you have a space constraint on your home drive (or a roaming profile in windows), this may be better off in some other place.

The location of this directory is placed in an idea.properties file in the bin/ directory of your AS is installed. Currently (AS 1.1.), the two variables are commented out and look like this:

The previous tutorials were suggesting enabling the two variables and changing the installed file itself. This posed two problems:

  1. First, you’d need admin rights or some alternative to have write access to the installed idea.properties file
  2. Then, more importantly, AS rewrites the file with each update

Therefore, here are the steps to a friendlier approach:

  • Copy the idea.properties file locally (e.g. in ${home}/.androidStudio.properties)
  • Enable the two properties:

  • Create an environment variable named STUDIO_PROPERTIES pointing to the local file:

Now, you can run AS and your cache directory will be created where you’ve specified.

HTH,


A little experiment: If you find this post and ad below useful, please check the ad out :-)