2

Android Studio complains that it can't launch the emulator due to a lack of space. The folder ~/.android contains (among others) the virtual devices and is therefore quite big. I would like to move it to another partition where there is more space. There are plenty of descriptions out there explaing how to move this directory: just move the directory and set the environment variable ANDROID_SDK_HOME. The problem is, all of these explanations are for Windows.

I have moved the directory and tried setting the environment variable in ~/.bashrc (which is sourced by ~/.bash_profile) and ~/.profile while Android Studio was not running

export ANDROID_SDK_HOME='/mnt/data/accessories/android'

and in ~/.pam_environment (as recommended here)

ANDROID_SDK_HOME=/home/user/data/accessories/android

Android Studio opens happily after the time it needs, creates a new ~/.android directory without saying a word and does not find the virtual devices.

It does not matter whether I am running android-studio from the command line or via an i3 shortcut.

I have rebooted the entire system before launching Android Studio - just in case.

I am using Arch Linux and Android Studio 3.2.

How do I move ~/.android on Linux?

2 Answers 2

3

I'm not sure what's up with the environment variables, but there's another approach you can take on Linux which should work here.

First, double check that you've moved the actual data, and have removed the ~/.android directory. Then run the following:

ln -s /mnt/data/accessories/android ~/.android

You can replace the second path in that command with whatever directory you moved the contents of ~/.android to.

What this is doing is creating a symbolic link in the old location pointing at the new location. WHen Android studio starts, it should see the link there, and just follow it, redirecting all accesses to ~/.android to the new location.

2
  • great idea. But it does not work quite as well as I would have expected. It didn't find the virtual devices so I just ended up removing the entire folder and linking ~/.android to a new, empty directory. Now it creates some files directly in the linked directory (as expected) and others in a .android subdirectory of the linked directory (which were located directly in ~/.android before, among those the directory containing the virtual devices).
    – jakun
    Commented Nov 2, 2018 at 21:58
  • @mosvy You're absolutely correct, fixed it in the answer. Commented Apr 11, 2020 at 23:02
0

There was a more intereting solution here: Move Android Studio Virtual Devices to Another Hard Drive on a Mac

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .