After upgrading Android Studio to the version 2.1 on my Linux box, it asked me to update the SDK tools. Then I got an error:
“No space left on device…”
I noticed that there were more people reporting this problem that is due to the fact the JVM uses, by default, the directory /tmp as the temporary directory. Having found a solution, I decided to write this post to try to help those with the same problem.
The cause is in the space that usually is reserved to this temporary directory: /tmp. Many Linux distros use this directory for temporary storage and mount it on a RAMFS (let’s say, a RAM drive) with about half of the RAM size. For instance, if your computer has 4Gb of RAM, the directory /tmp should have 2Gb. So, as some update SDK files of Android Studio have about this size, or more, during the download, the directory /tmp will fill up and become with no space left.
The solution: Tell the Java VM to use another directory as the default directory with the argument:
In my case, I decided to create a directory “tmp” in my “home” and set this argument in the configuration files of Android Studio.
For that, in Android Studio, we go to the menu “Help > Edit Custom VM Options”.
AS will then open a document named “studio64.vmoptions” located in ~/.AndroidStudio2.1/studio64.vmoptions.
(The path might be different, depending on the AS version you’re running).
In this file, we have the options that are sent to the JVM to execute AS. So, here we add a line, for instance, for a user named “carlos”:
You should avoid using “~”. For instance, if you type ~/tmp, a directory ‘~’ will be created in your home directory.
After restarting Android Studio, the updates should now run successfully! However, make sure that you have space enough in your home directory! You can always choose another directory, but you must be sure you have enough permissions to use it.
NOTE: If you experience similar problems when compiling with “gradle”, this solution may also solve the problem!