-4

I am trying to download an android system image on Android studio in order to emulate apps. The issue is android studio is failing to download the system image. After looking at the log it says I have no space left on my device yet I have 960GB left on my laptop.

The exact error message is

2017-11-28 20:32:13,136 [d thread 8]   INFO - s.RepoProgressIndicatorAdapter - Downloading https://dl.google.com/android/repository/extras/intel/addon2-1.xml   
2017-11-28 20:32:13,238 [d thread 8]   WARN - s.RepoProgressIndicatorAdapter - java.io.IOException: Cannot download 'https://dl.google.com/android/repository/extras/intel/addon2-1.xml': No space left on device, response: 200 OK

Another important piece of information is my laptop runs solus Linux.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
ProPain
  • 1
  • 2
  • 2
  • 2
    Both Info and Warn messages are non-critical notices to the user in Linux, and, when displayed, do not indicate that procedure failed (no matter how dire they sound). You may be chasing the wrong error. (Overall, this seems like some particularism, i.e., not running the command in sudo, chmod'ing the entire harddisk as non-writable, etc.) – HoldOffHunger Nov 29 '17 at 02:00
  • 2
    `No space left on device` seems like an obvious error. Are you downloading to a temporary partition? – OneCricketeer Nov 29 '17 at 02:32

1 Answers1

0

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,

  1. Make android studio use another temporary folder
  2. Increase /tmp size temporarily to complete updates or compiling
  3. 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.

Diaz
  • 241
  • 1
  • 3