43

I have such exaption

InvalidPathException: Illegal char  at index 9: C:\Users\??????\.android\avd\1.avd (show balloon)

when trying to create emulator. Can I change the location of directory .android?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Ron D
  • 579
  • 1
  • 5
  • 8

7 Answers7

46
  1. Open control panel
  2. Then go to System
  3. Then go to Change Environment Variables of the User
  4. Then click create a new environment variables
  5. Create a new variable named ANDROID_SDK_HOME
  6. Set its value to your Android directory, like C:/users/<username>/.android
keipa
  • 702
  • 1
  • 8
  • 17
38

I tried suggested solution but did not work for me. In my case I have to add a different variable so steps for me were:

  1. Open Control Panel
  2. Then go to System and Security
  3. Then go to System
  4. Then go to Advanced system settings
  5. Then go to Change Environment Variables of the User
  6. Then click create a new environment variables
  7. Create a new variable named ANDROID_AVD_HOME
  8. Set its value to your Android directory, like C:/users/<username>/.android
Javier
  • 483
  • 1
  • 5
  • 11
  • 1
    Works for Android Studio 2021.1. For already existing devices - copy everything to new folder and edit 'path' in all .ini files – Swayok Apr 10 '22 at 11:08
29

How can I change the path to android\avd in my Android Studio ?

Let say you want to move avd directory from it's default C:\users\<username>\.android\avd to D:\Development\avd

  1. Move avd directory to desired location (ex. D:\Development\avd)
  2. Change or add environment variable ANDROID_AVD_HOME : D:\Development\avd
    • On Windows: Control Panel > System > Advanced system settings > Environment Variables
    • If variable doesn't exits Click New... and fill with aforementioned data.
    • If variable exists then select variable, click on Edit... and replace variable value with the new path (ex. D:\Development\avd)
  3. If you have already AVD, change avdName.ini to D:\Development\avd\avdName (ex. D:\Development\avd\Nexus_S_API_22.avd)
Neo Anderson
  • 5,957
  • 2
  • 12
  • 29
Isma Rekathakusuma
  • 856
  • 12
  • 18
14

There is a simple way to move avd(in windows):

  1. open the directory: C:\Users\Username\.android\avd, you will find the directory named with your AVD and a .ini file

  2. move the directory to your desirable path, then change the path variable in the .ini file to the new location.

  3. start the Android studio, you will find that the AVD can work properly.

Nicolas Gong
  • 520
  • 5
  • 9
  • Good solution: an idea is to move virtual device after its creation instead of changing default avd location generally (like in most rated solution) – Antares Jan 23 '23 at 12:16
8

Just move the emulator folder(folder that ends with .avd) to new location and keep the .ini file in same location then change the path to new location in .ini file.

No environment variable needed to be changed or added.

old path path=C:\Users\nero\.android\avd\Android_Q.avd

new path path=D:\androidemuators\avd\Android_Q.avd

You can keep your emulator anywhere just need to tell .ini config file where your emulator is located.

Nero
  • 111
  • 1
  • 4
3

Simple with Image solution here, no need to edit Environment Variables here.

  1. Go to C:\Users\<PCname>\.android and move the avd folder to your desired location. Example D:\Programming\Android Studio\avd
  2. Open avd folder and edit every .ini files, each one of these is represent to your emulator.
  3. Edit file location. See image below for your reference.
  4. Restart your Android Studio.

These are .ini files:

inifiles

Old path:

oldpath

New path:

newpath

emen
  • 6,050
  • 11
  • 57
  • 94
DL Studio
  • 267
  • 3
  • 7
0

Had the same problem. The reason was that ANDROID_AVD_HOME pointed to my user directory which had a space and umlaut in it. Obviously that causes some trouble with Android Studio. So defining a system wide ANDROID_AVD_HOME point to d:\development\avd\ solved the problem.