How can I change the path to android\avd in my Android Studio
Asked Answered
N

8

47

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?

Needlepoint answered 9/11, 2016 at 6:43 Comment(2)
What is character at index 9? Your windows username?Caneghem
Yes, it's my username.Needlepoint
L
50
  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
Lefkowitz answered 9/11, 2016 at 6:50 Comment(3)
without .android in path C:/users/<username> worked for meLingonberry
I don't want to change path of SDKCourtney
Starting with Android Studio 4.2, the ANDROID_SDK_HOME environment variable is deprecated and the default location of the emulator configuration directory is $ANDROID_PREFS_ROOT/.android/.Ceja
D
42

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
Dunaway answered 13/11, 2019 at 14:34 Comment(1)
Works for Android Studio 2021.1. For already existing devices - copy everything to new folder and edit 'path' in all .ini filesCentralize
K
34

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)
King answered 29/4, 2020 at 1:33 Comment(1)
...and restart Andriod Studio after changing varsSapp
A
15

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.

Anaemia answered 24/11, 2019 at 0:12 Comment(1)
Good solution: an idea is to move virtual device after its creation instead of changing default avd location generally (like in most rated solution)Powerless
S
9

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.

Sondra answered 7/4, 2021 at 7:12 Comment(0)
I
5

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

Imprisonment answered 30/10, 2021 at 11:51 Comment(1)
The better way to change the pathLoudspeaker
D
1

Here is an updated solution worked for me in 2024.

Prerequisite

Accroding to this doc, Androdi Studio locates avd dictionary through an environment variable called ANDROID_AVD_HOME.

The default value of ANDROID_AVD_HOME is $ANDROID_EMULATOR_HOME/avd/, where $ANDROID_EMULATOR_HOME is $HOME/.android/.

Steps

  1. Find your avd dictionary.

  2. Move avd dictionary to a new place, suppose to be D:\avd.

  3. There are many .ini files in the avd dictionary. Open these files, edit path in these files.

(see the answer under this question from DL Studio for your reference)

  1. Create a new environment variable named ANDROID_AVD_HOME.

  2. Set its value to D:\avd.

Debroahdebs answered 26/4 at 16:8 Comment(0)
E
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.

Echt answered 26/11, 2020 at 10:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.