121

After installation of Android SDK, the folder .android was created on the E:\ drive. As far as I know, this is the default folder of Android Virtual Devices for configuration files.

How can I move .android folder to a different location?

(eg. from E:\.android to E:\Android\.android)

Dariusz Bacinski
  • 8,324
  • 9
  • 38
  • 47
  • 2
    Possible duplicate of [Possible to change where Android Virtual Devices are saved?](http://stackoverflow.com/questions/2841766/possible-to-change-where-android-virtual-devices-are-saved) – Xcalibur Nov 21 '16 at 02:51

9 Answers9

235

I've found the answer.

  • Move .android folder to E:\Android
  • Create environment variable called ANDROID_SDK_HOME and set its value to E:\Android

Setting the environment variable on Windows XP or Windows 7:

  1. Right-click on My Computer and choose "Properties"
  2. Click the "Advanced" tab
  3. Click the button "Environment Variables".
  4. Add New variable
Dariusz Bacinski
  • 8,324
  • 9
  • 38
  • 47
  • 5
    Thank you, this worked for me. I was running out of space on C: where it initially put all the AVD files and was causing other problems with the computer. – MichaelF Mar 21 '12 at 12:39
  • 4
    Thanks a lot. Many other sources suggested changing the `ANDROID_SDK_HOME`, but the detail about copying the `.android` folder was the last missing piece. – luiscubal Oct 18 '12 at 23:08
  • @luiscubal, just using window explorer copy and paste. – Cheung Aug 28 '13 at 03:25
  • 7
    On Windows 10, I had to make sure to add ANDROID_SDK_HOME within the existing PATH variable. It did NOT work when I added it as a new environment variable. – blizz Aug 24 '16 at 14:13
  • 5
    I had to make sure .android was a subdirectory of the ANDROID_SDK_HOME for it to be found. This makes sense to me as the .android directory is not the sdk directory (at least in Android Studio 2.2.2) – Xcalibur Nov 21 '16 at 03:37
  • 1
    thanks, this is the correct answer. is this possible to use the same method for changing the location of `.AndroidStudio2.1` and `.gradle` folders of Android Studio? – ir-tech Dec 14 '16 at 12:27
  • 3
    @ir-tech you can override the default `~/.gradle` location by setting the GRADLE_USER_HOME environmental variable – mateor Feb 28 '17 at 17:41
  • 1
    If your AVDs don't work anymore, you can recreate them. – Dino Velić Oct 11 '17 at 13:25
  • I had to update `path` in each avd .ini file, otherwise they were showing up as corrupted. – Artem Russakovskii Feb 22 '20 at 15:52
  • Still valid instructions. I can use Android Studio and Visual Studio 2019 without problems, after setting the variable. – Mário Meyrelles May 27 '21 at 18:20
26

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 searches the avd directory in the order of the values in $ANDROID_AVD_HOME, $ANDROID_SDK_HOME/.android/avd/, and $HOME/.android/avd/.

This page provides the list of environmental variables supported by android studio: https://developer.android.com/studio/command-line/variables

rpattabi
  • 9,984
  • 5
  • 45
  • 53
RonTLV
  • 2,376
  • 2
  • 24
  • 38
11

If you go for this answer be aware of this note: Starting with Android Studio 4.2, the ANDROID_SDK_HOME environment variable is deprecated and has been replaced with ANDROID_PREFS_ROOT.

MCP2019
  • 111
  • 1
  • 3
9

The path set in ANDROID_SDK_HOME must exist. Otherwise the default path will be chosen. But it is not necessary to include .android. The AVD Manager creates a .android folder, if not found in ANDROID_SDK_HOME.

cagdasalagoz
  • 460
  • 1
  • 12
  • 22
robbash
  • 985
  • 10
  • 21
  • I confirmed these instructions are correct as of Android Studio 2.2.2 in 2016. As long as your .android folder is a subdirectory of the ANDROID_SDK_HOME it works. It can be a user or system environment variable – Xcalibur Nov 21 '16 at 03:36
6

In addition to the answer provided by Dariusz Bacinski, you have to include the .android folder in the ANDROID_SDK_HOME path. It was not working for me if I did not include the .android folder.

Dariusz Bacinski
  • 8,324
  • 9
  • 38
  • 47
shmoo
  • 119
  • 2
  • 6
  • I've tried both, still not working for me either way. I have a honeycomb tablet and a gingerbread phone to test on, but one of my computers doesn't like Motorola's drivers for whatever reason, so I need an AVD. – Mike Oct 20 '11 at 16:39
  • hmm, nevermind. Changing the debug keystore from default seems to have solved the problem for some reason. – Mike Oct 20 '11 at 16:43
  • This is not correct - it will look for a .android SUB-folder under the ANDROID_SDK_HOME, so following these instructions does not work. See the answer below – Xcalibur Nov 21 '16 at 03:35
  • I already copied `avd` inside `%ANDROID_SDK_HOME %\.android`, so no more folders were needed. – CoolMind Mar 29 '19 at 15:53
2

If you want to move just the AVD folder and not everything else, use those environmental variables.

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.

rtsketo
  • 1,168
  • 11
  • 18
2
  1. (Optional) Download Rapid Environment Editor
  2. Add a new system variable

ANDROID_PREFS_ROOT = D:\IDE\Externals\ANDROID_PREFS_ROOT (The folder you want to move to.)

  1. Save and you're done.
Cyber Avater
  • 1,494
  • 2
  • 9
  • 25
1

If you would like your avd sdcard and files on a different drive, go to $HOME/.android/avd and move the folder <AVD_NAME>.avd to someplace else

Edit $HOME/.android/avd/<AVD_NAME>.ini and change

path=<NEW_AVD_LOCATION>/<AVD_NAME>.avd

$HOME depends on your system. On windows it can be your user directory

Dennis Maina
  • 11
  • 1
  • 5
0

Chosen answer is kinda outdated.

As of Giraffe | 2022.3.1 (Stable): when changing the default android avd folder, you need to add a new environment variable for ANDROID_USER_HOME. The value should lead to the location of the new folder, in your case:

ANDROID_USER_HOME = E:\Android\.android

If you have android studio with a lower version (4.3 or earlier), you have to use ANDROID_SDK_HOME instead of ANDROID_USER_HOME.

ANDROID_SDK_HOME = E:\Android

To override the user preferences location for those older tools, set ANDROID_SDK_HOME to the parent directory you would like the .android directory to be created under.

If you have AVDs and you're not able to run them after changing the location of the .android folder.

Error thrown when running an emulator

Then you might want to look at the *.ini configuration file of each of your AVDs. It is located inside the avd folder E:\Android\.android\avd Inside the AVD folder

If each emulator's path does not lead to the new specified location, correct it. Correct way of AVD paths

Firate
  • 105
  • 5