Create Android Studio Project / Workspace on external, network mounted drive under Ubuntu 18.04

Use external, network connected drives for Android Studio projects.

It’s really simple:

1. create mount point under /mnt

sudo mkdir /mnt/studio

sudo chmod 777 /mnt/studio

2. mount external drive

sudo mount -t cifs -o username=my_user_name,password=my_password,vers=3.0,file_mode=0777,dir_mode=0777 //192.168.x.x/android-studio-projects/ /mnt/studio

3. if you want to mount external drive while Android Studio starts, use „fstab“. Open /etc/fstab file and edit:

sudo gedit /etc/fstab

add line:

//192.168.x.x/android-studio-projects /mnt/studio cifs vers=1.0,noauto,rw,users,username=my_user_name,password=my_password 0 2

reload fstab settings:

sudo mount -a

open studio.sh file under Android Studio/bin and add this code in the head:

if mount | grep /mnt/studio > /dev/null; then
    echo "/mnt/studio is mounted!"
else
    echo "Try to mount /mnt/studio!"; mount /mnt/studio;
    if mount | grep /mnt/studio > /dev/null; then
        echo "/mnt/studio has been mounted!"
    else
        echo "/mnt/studio can't be mounted!"; exit;
    fi
fi

if you get mount errors like „Mount error(22)… Invalid Argument…“, install cifs-utils:

sudo apt-get install cifs-utils

4. start Android Studio, click „Open an existing Android Studio project“ (if the project already exists on external drive) and select an project under /mnt/studio, or start new project under /mnt/studio

Done!