Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to change where Android Virtual Devices are saved?

Add a new user environment variable (Windows 7):

  1. Start Menu > Control Panel > System > Advanced System Settings (on the left) > Environment Variables

  2. Add a new user variable (at the top) that points your home user directory:

    Variable name: ANDROID_SDK_HOME
    Variable value: a path to a directory of your choice

AVD Manager will use this directory to save its .android directory into it.

For those who may be interested, I blogged about my first foray into Android development...
Android "Hello World": a Tale of Woe

Alternatively, you can use the Rapid Environment Editor to set the environment variables.


Based on official documentation https://developer.android.com/studio/command-line/variables.html you should change ANDROID_AVD_HOME environment var:

Emulator Environment Variables

By default, the emulator stores configuration files under $HOME/.android/ and AVD data under $HOME/.android/avd/. You can override the defaults by setting the following environment variables. The emulator -avd command searches the avd directory in the order of the values in $ANDROID_AVD_HOME, $ANDROID_SDK_HOME/.android/avd/, and $HOME/.android/avd/. For emulator environment variable help, type emulator -help-environment at the command line. For information about emulator command-line options, see Control the Emulator from the Command Line.

  • ANDROID_EMULATOR_HOME: Sets the path to the user-specific emulator configuration directory. The default location is
    $ANDROID_SDK_HOME/.android/.
  • ANDROID_AVD_HOME: Sets the path to the directory that contains all AVD-specific files, which mostly consist of very large disk images. The default location is $ANDROID_EMULATOR_HOME/avd/. You might want to specify a new location if the default location is low on disk space.

After change or set ANDROID_AVD_HOME you will have to move all content inside ~user/.android/avd/ to your new location and change path into ini file of each emulator, just replace it with your new path


Modify the file "virtual_android2.2.ini" in "C:\Documents and Settings{your windows login}.android\avd\":

target=android-8
path=E:\android_workspace\avd\virtual_android2.2.avd

And move the folder "virtual_android2.2.avd" from "C:\Documents and Settings{your windows login}.android\avd\" into "E:\android_workspace\avd\".


Move your .android to wherever you want it to.

Then, create a symlink like this:

# In your home folder
$ ln -s /path/to/.android/ .

This simply tells Linux that whenever the path ~/.android is referenced by any application, link it to /path/to/.android.


Go to the Android tools directory. Edit the android.bat command file. At about the end of the command file, find a line similar to

call %java_exe% -Djava.ext.dirs=%java_ext_dirs% -Dcom.android.sdkmanager.toolsdir="%tools_dir%" -Dcom.android.sdkmanager.workdir="%work_dir%" -jar %jar_path% %*

and replace

call %java_exe%

with

call %java_exe% -Duser.home={your_prefer_dir}

where {your_prefer_dire} is your preferred directory without braces but add doublequotes,

e.g.

call %java_exe% -Duser.home="E:\Program Files (x86)\android-sdk-windows"

Check this out. using the android command to create avd you can specify where to place files.

-p --path     Location path of the directory where the new AVD will be created