27

Just to tinker with it, last night I installed the Android Studio/SDK, and both during install and use, it repeatedly blew my 2Gb /tmp partition. Is there any way to tell this monster to use something other than /tmp, especially for downloading/unzipping?

Fedora release 20 (Heisenbug)

Thanks

comrade
  • 4,590
  • 5
  • 33
  • 48
Chris Moller
  • 461
  • 1
  • 4
  • 8
  • This is a link to the current bug tracker for this problem (the more people that star it, the more likely it is to be fixed) https://issuetracker.google.com/issues/72581483 – EpochGrinder Apr 08 '18 at 14:26
  • Apparently this was fixed: https://issuetracker.google.com/issues/37092608 – OrangeDog Jun 29 '21 at 11:55

15 Answers15

41

Setting -Djava.io.tmpdir=whatever didn't work for me. I simply created $HOME/tmp/PackageOperation04 and then created a symlink from /tmp.

cd ~
mkdir -p tmp/PackageOperation04
cd /tmp
ln -s $HOME/tmp/PackageOperation04

This way the Android SDK uses my /home partition instead of /tmp for this.

slartidan
  • 20,403
  • 15
  • 83
  • 131
user3150128
  • 455
  • 6
  • 9
  • Yeah, I couldn't figure out where to tweak the VM options for the initial startup/SDK download/configure either, and I found that it would use the vmoptions for everything except downloading packages. In order to bootstrap the first startup I had to do this for both the `PackageOperation01` and `PackageOperation04` directories. –  Jun 15 '17 at 15:20
  • 2
    The thing is, the created link seems to always be removed at certain steps of installation – Syakur Rahman Aug 02 '17 at 02:47
  • This appears to be the only working solution in recent Android SDK versions (25.2.5 tested here). – drizzd Oct 18 '17 at 09:00
  • Folder might change to PackageOperation01 in android studio 3.0. Please check directory in /tmp for right folder name. – ashishWaghmare Mar 03 '18 at 22:44
  • 1
    android-studio created in my case different folders and always ignored the already existing. If you have the same problem try Paul Ratazzi's solution below – fupduck May 18 '18 at 12:55
  • @user3150128 Thank you for this workaround, you rock! :) – Izabela Orlowska Jun 21 '18 at 10:38
  • I just symlinked PackageOperation01 till 09. It seems to rotate. It should accept a tempdir parameter though if its gonna dump >4GB in there... – W. Goeman Sep 04 '18 at 21:10
17

You can change the location of the temporary directory used by the Java Virtual Machine running Android Studio. In Android Studio 2.0 or later, select Help -> Edit Custom VM Options. This will create a copy of the installation's vmoptions file in your own configuration directory and open it in the editor. Add the following line and restart:

-Djava.io.tmpdir=<directory>

where <directory> is an absolute path to a directory in a partition with enough space. If <directory> doesn't exist, it will be created the next time Android Studio is started.

You can also edit the file directly (and need to in versions prior to 2.0), but it's location varies depending on the platform version and possibly an environment variable setting. See Configuring Android Studio: IDE & VM Options, JDK, etc. for the details.

An alternative solution would be to increase the size of /tmp which in your case is most likely a tmpfs partition and thus easily resizable.

Paul Ratazzi
  • 6,289
  • 3
  • 38
  • 50
  • 2
    I tried this approach by adding the above line to studio64.vmoptions (in the AS bin directory). AS itself now uses this tmpdir, but the SDK installer ignores it and creates a /tmp/PackageOperation01 directory which it uses to download & unzip the SDK's. – Lieuwe Nov 15 '16 at 15:37
  • On my system (Ubuntu 16.04 LTS, AS 2.2.2), the SDK Manager uses a temp directory relative to the SDK location. I don't see a way to change this without changing the location of the entire SDK. That said, this really seems like a completely different question (JVM temp vs. SDK temp), so maybe your problem would get better exposure with a fresh new question. – Paul Ratazzi Nov 15 '16 at 18:01
  • 2
    I presume the OP was doing a first run of AS at which point it will install the latest Android SDK. It is the installation of that SDK that 'blows' (his words) the /tmp directory. I have since found that once you have installed that initial SDK, any further SDK installs will correctly use the tmp directory as specified by -Djava.io.tmpdir. – Lieuwe Nov 16 '16 at 13:56
8

Chris Moller's answer made me curious to check source code if there is better way how to fix this /tmp/ issue. And I can see that Android studio 2.3 has option STUDIO_VM_OPTIONS which allows specify file with JDK options.

So you can just use snippet below and /var/tmp/androidTmp will be use instead of /tmp

echo "-Djava.io.tmpdir=/var/tmp/androidTmp" > ~/android-studio-tmp.fix
STUDIO_VM_OPTIONS=~/android-studio.fix android-studio
Dalibor
  • 99
  • 1
  • 4
  • Thanks, the tmpdir in the vmoptions file is lost with every upgrade, really annoying. – Alex Mar 25 '17 at 14:09
  • 1
    For people hitting this issue when downloading system images, you need to specify a different tmp directory in $JAVA_OPTIONS, not only on $STUDIO_VM_OPTIONS (same options, i.e "-Djava.io.tmpdir") – Mauricio Pasquier Juan Aug 31 '17 at 21:38
7

Did a little poking around in the code. The solution is to to start the JVM with a command-line argument that overrides the default tmpdir path:

-Djava.io.tmpdir=whatever

There may be more subtle ways to do it but all I did was edit .../android-studio/bin/studio.sh to replace

VM_OPTIONS=""

with

VM_OPTIONS="-Djava.io.tmpdir=/mnt/disk5/android/tmp"

Chris Moller
  • 461
  • 1
  • 4
  • 8
7

From this comment on a blog post work for me:

  • Create a directory

    $ mkdir /opt/android-studio/tmp

  • At the top of studio.sh add:

    export _JAVA_OPTIONS=-Djava.io.tmpdir=/opt/android-studio/tmp

Amsrd
  • 71
  • 1
  • 2
3

Another option would be to temporarily increase the size of your /tmp partition. To do so, you need to execute the following: sudo mount -o remount,size=10G /tmp/

This would increase the size of your partition to 10GB. Please use df -h to check that everything went well.

Igor
  • 991
  • 3
  • 12
  • 27
2

I succeed to unzip manually a system image to Sdk/system-images/android-xx after android studio flooded my 4GB tmp partition ...

Thus we have just to unzip to the right place.

Apparently it creates a /tmp/PackageOperationxx for each download, perform the download, ask you to proceed, unzip the content in tmp and move it to the right place.

Seriously android guys ...

1

You can use a file for your /tmp:

as root:

create a file the desired size ((example for a 10 GiB /tmp size):

dd if=/dev/zero of=/path/to/your/tmp_dir bs=1024M count=10

create a filesystem on it:

mke2fs -j /path/to/your/tmp_dir

the partition is ready, mount it:

mount -t ext3 -o loop /path/to/your/tmp_dir /tmp

source : https://www.yourhowto.net/increase-tmp-partition-size-linux/

azotlikid
  • 11
  • 2
1

After previous suggestions did not work for me, I want to add another (not very clean) solution:

Upon starting to install a new virtual device (still using /tmp) the file

~/Android/Sdk/system-images/android-< version >/google_apis/x86/.installer/.installData

is created, which contains the temp path. Cancel the download, edit the temp path to your desired folder and restart the installation of the device.

I later realized that the solution adding -Djava.io.tmpdir=< tempdir > as suggested by Paul Ratazzi via Help -> Edit Custom VM Options did not work for me, since it was added to android-studio/bin/studio64.vmoptions but adding it to android-studio/bin/studio.vmoptions instead did the job for me. That is probably the better way to do it...

Dmitriy
  • 5,525
  • 12
  • 25
  • 38
morp
  • 11
  • 1
1

Setting java.io.tmpdir as others have said used to work for me, but unzipping system images are still using /tmp in Android Studio 3.0.1. It wasn't reliably using the same PackageOperation0x directories so I didn't really want the special symlinks for them as in user3150128's answer.

Since it's only a problem when needing new SDKs and images, I ran Android Studio once and successfully did the update by setting TMPDIR on the command line:

$ TMPDIR=/path/to/bigger/tmp/dir /path/to/android/studio.sh
Paul Stephenson
  • 67,682
  • 9
  • 49
  • 51
0

I fought with the "no space left on device" problem for almost a week. (I will not be beaten!) I tried everything I found here and on other sites and the problem continued. I finally got Android studio completely installed and working correctly using the following approach:

  1. I created a folder named PackageOperation01 on a partition with 100G space.
  2. I went to the tmp directory and removed everything I felt was safe to remove, including PackageOperation01 folder.
  3. In the tmp directory I created a link pointing to the new PackageOperation01 folder I had created.
  4. I named the link PackageOperation01. This allowed me to install ALMOST everything.

I still had two errors (.."no space..."). Going back to the tmp directory I found my link to PackageOperation01 had been removed by the installer and a new directory named PackageOperation07 had been created.

  1. I removed PackageOperation07 from tmp and created a new folder named PackageOperation07 on my large partition beside PackageOperation01.
  2. I recreated the link to my PackageOperation01 folder and created a new link to the PackageOperation07 folder.

This time Android Studio installed with no errors.

Meyer
  • 1,662
  • 7
  • 21
  • 20
0

Solution with symbolic links will not work because at the presence directory or link /tmp/PackageOperation0* Android Studio creates a directory /tmp/PackageOperation0* + 1.

For example we have created a symbolic link /tmp/PackageOperation01 and and started to download system images, Android Studio just create directory /tmp/PackageOperation02 and will work with her.

0

I have it resolve by changing tmpfs reference folder to /var/tmp. Add this after line containing #!bin/sh in android-studio.sh :

export TMPFS=/var/tmp

0

I have an alternate version using symlinks. The other solutions didn't work for me, as the PackageOperation0* symlinks got always deleted. But creating a symlink inside this folder for the unzip folder did work:

cd ~
mkdir -p tmp/PackageOperation01
mkdir -p tmp/PackageOperation01/unzip
cd /tmp/PackageOperation01
ln -s $HOME/tmp/PackageOperation01/unzip unzip
0

Here is What I did and worked:

mkdir -p ~/PackageOperation01 /tmp/PackageOperation01
sudo mount --bind PackageOperation01 /tmp/PackageOperation01
$ANDROID_HOME/tools/bin/sdkmanager "system-images;android-29;google_apis;x86_64"
yukashima huksay
  • 5,834
  • 7
  • 45
  • 78