Home > Technology > Computer Science > Android Studio updates error under Linux

Android Studio updates error under Linux

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:

-Djava.io.tmpdir=/path/to/temp

In my case, I decided to create a directory “tmp” in my “home” and set this argument in the configuration files of Android Studio.

Android Studio - Setting custom VM optionsFor 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”:

-Djava.io.tmpdir=/home/carlos/tmp

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!



About Carlos Santos

Frequency of master studies in Electrical and Computer Engineering. Freelancer developer (also works remotely): Websites, Web Applications (JAVA and PHP), J2SE/J2EE, C/C++ and Android. Private instructor and professional trainer in computer science and electrical engineering. Teaches in classrooms and remotely using Skype and Team Viewer. Interests: Music, audio, video, science, astronomy and mythology.

11 comments

  1. Thank you very much! My virtual device works now.

  2. For me too. Thanks a lot. !

  3. Thanks a lot, Carlos!
    Your solution was helpful for me. I’ll share your link with my partners.

  4. Thanks for this article. It helped when no other solutions worked.

  5. I tried this, and made sure jps -lvm reflects my change, but still get the same issue in Android Studio: “No space left on device”. I’m using the gradle-experimental plugin since my project includes some native code.

    Does anyone know what device is actually full? Is there a RAM disk created during build? I have 3.5GB free on my / partition and 700GB free on my home folder partition…

    • As far as I remember, I just needed to make the changes in the file “studio64.vmoptions” and I didn’t make any other changes or run any other command.
      Are you setting up some directory on your home partition to use with -Djava.io.tmpdir ?
      After editing and changing the file “studio64.vmoptions” you’ll need to restart AS. Make sure you are using the correct configuration path according to your AS version.

      Good luck! 🙂

      • Hi!

        Yeah, I created ~/tmp and pointed java.io.tmpdir to it, and restarted AS. I also verified that my studio64.vmoptions file was indeed parsed, and that jps -lvm reflected the change. But still no luck. What I cannot seem to get from the stack trace though is what partition is reported as full – like I said none of my partitions is actually full, so I’m starting to think there’s a temporary RAM disk or something involved here.

        I found a lot of other similar questions regarding gradle’s temp dir, and issues related to running the emulator without enough space, but I’m running on device and I have 3.5 GB free, so it just doesn’t seem applicable to me…

        Maybe the native compiler or linker is doing something strange. I’ll probably file a bug with google on this.

      • Indeed, the main problem of /tmp is that it is mounted on a RAM disk! Now it’s not common to find a similar situation on ~/tmp.
        Anyway, just try something like ~/astemp or any other name… Indeed that’s really strange.

  6. Hey Carlos, thanks a lot i did it and worked. Can i share your solution link in my webpage? thanks.
    Luis

Leave a Reply

Your email address will not be published and it is optional.