This is a very common error. Your temporary folder your system uses as a cache is full. Now, the tmp is cleaned on every reboot. However, Android Studio uses a lot of space. Below, I go over your options.
How to find out if /tmp is the problem?
On the terminal, type:
df -h | grep -e 'Filesystem' -e '/tmp'
On the output, look at 'Use%' column. If the percentage is high then you are running out of space on tmp. If you do a lot of compiling or installations this will be an issue later on as well.
You have three options,
- Make android studio use another temporary folder
- Increase /tmp size temporarily to complete updates or compiling
- Increase /tmp all the time. Usually an OS sets the /tmp folder to
half the size of the ram. I'm assuming /tmp is not a separate
partition.
Option 1. Find out where android studio is installed and modify studio.sh file to pass on a variable. When android studio boots up, the env variable tells android manager to use the temporary folder specified.
Step 1. Find where android studio is installed. It's usually in the /opt/android-studio folder. To make life simple, the following will contain the folder directory with pattern 'android-studio/bin' from the whereis -l output.
DROID_BIN=$(whereis -l android-studio | grep 'android-studio/bin' | awk -F'bin: ' '{print $2}')
Step 2. Use directory to open 'studio.sh' file with vim. Usually, this is /opt/android-manager/bin/studio.sh
sudo vim $DROID_BIN/studio.sh
Step 3. Copy and paste the following lines on the beginning of studio.sh . I added comments as a reminder if you ever take a look at it on a future date.
On Vim press [i] to edit. Copy from browser with [Ctrl] + [c] and Paste into vim with [Ctrl] + [Shift] + [v] keys.
# _JAVA_OPTIONS was added to replace /tmp folder because it runs out of
# space and causes failure with android studio updates.
export _JAVA_OPTIONS=-Djava.io.tmpdir=/shared/tmp
Save and exit by pressing [Esc] then type ":wq"
Start android studio and try the updates again. This time, updates should be successful.
For Both Option 2 & 3 Check /tmp and make sure it's not a separate partition.
df -h | grep -e 'Filesystem' -e '/tmp'
On the output, look at the Filesystem column. If that Filesystem displays a backslash followed by three letters like /sda or /sdb then don't continue and look for other instructions.
If Filesystem Column is tempfs then continue...
Option 2. Increase the size of /tmp temporarly.
sudo mount -o remount,size=6G,noatime /tmp
That's it. Done.
Option 3. Increase size of /tmp all the time. This is useful if you see the "No space error" repeatedly with multiple programs or activities.
Step 1. Backup fstab.
cp /etc/fstab ~/fstab_BACKUP
Step 2. Check if you have an existing entry for 'tmpfs /tmp'
cat /etc/fstab | grep tmp
Step 3. if nothing returns on the terminal, then paste the following line. Change 6G to the size that you want for /tmp.
sudo sed -i '$a tmpfs /tmp tmpfs rw,nodev,nosuid,size=6G 0 0' /etc/fstab
If you have an existing entry, manually change the size of the drive with vim or any terminal text editor.
sudo vim /etc/fstab
you will see something similar to this:
------------/etc/fstab----------------------
...
tmpfs /tmp tmpfs rw,nodev,nosuid,size=4G 0 0
...
Change the size integer to the size your want. For example, replace 4G with 6G.
Save & Quit. On vim, press [Esc] and type ":wq"
Finally,reboot your computer.
Hope this helps. Instructions provided at your own risk.