Android Studio takes up a lot of space with its Sdks and virtual devices. The home folder gets full quickly. One option would be to move the entire Android Studio suite to its own folder in one of the system folders. We will use /opt folder but /usr/local can also be used (I used that before).
First, create the directory structure at /opt
$ su
$ cd /opt
$ mkdir Android
The /opt/Android folder will hold the Android Studio, the Sdks, and the AVDs.
$ mv /home/me/android-studio /opt/Android
$ mv /home/me/Sdk /opt/Android
The AVD folders are trickier as they are in the hidden folders in the user's’ home directory.
$ cd /home/me/.android
$ mv avd /opt/Android
Now we need to link the moved folders so that Android Studio can access them.
1. Link the AVD folder as normal user
Open another terminal as the regular user
$ cd ~/.android
$ cd ~/.android
$ ln -s /opt/Android/avd avd
Verify that the link points to the right directory with
$ ls -l
$ ls -l
lrwxrwxrwx 1 me mygroup 16 Oct 13 09:46 avd -> /opt/Android/avd/
2. Create a desktop file for Android Studio
This will allow the user to start Android Studio from the Ubuntu dash. Open terminal as a regular user.
$ cd ~/.local/share/applications
$ gedit android-studio.desktop
And add these values in the file and save it.
[Desktop Entry]
[Desktop Entry]
Name=Android Studio
Exec=/opt/Android/android-studio/bin/studio.sh
Icon=/opt/Android/android-studio/bin/studio.png
Terminal=false
Type=Application
Categories=Utility;Application;
Exec=/opt/Android/android-studio/bin/studio.sh
Icon=/opt/Android/android-studio/bin/studio.png
Terminal=false
Type=Application
Categories=Utility;Application;
3. Link the Sdk location from inside Android Studio
Open the Android Studio from dash (start typing android and it should pop up along with the Android Studio icon)
File -> Settings -> System Settings -> Android Sdk
File -> Settings -> System Settings -> Android Sdk
Set the path to the Android Sdk location
If we have moved the Project directory then we will need to open one project manually and Android Studio will automatically detect the new location of the projects.
Notice that Android Studio with all its packages takes upwards of 9 GB
$ cd /opt/Android/
$ du -sh
8.8G .
Comments