Android Studio: Change the Cache Location
1 min read

Android Studio: Change the Cache Location

Android Studio: Change the Cache Location

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:

#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE config
# folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
# idea.config.path=${user.home}/.AndroidStudio/config

#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE system
# folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
# idea.system.path=${user.home}/.AndroidStudio/system

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:

    #---------------------------------------------------------------------
    
    #
    
    idea.config.path=${user.home}/no-backup/.AndroidStudio/config
    
    idea.system.path=${user.home}/no-backup/.AndroidStudio/system
    
    #
    
    #---------------------------------------------------------------------
    
  • Create an environment variable named STUDIO_PROPERTIES pointing to the local file:

    export STUDIO_PROPERTIES=${home}/.androidStudio.properties
    

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

HTH,