我已经在运行Windows XP的机器上设置了Android SDK和Eclipse, avd (Android虚拟设备)保存到“文档和设置\user\。默认为Android。有没有办法改变这种行为?我把所有其他组件都保存在一个单独的分区上的目录中,并希望所有内容都得到整合。显然不是什么大问题,但有人知道解决办法吗?


当前回答

根据官方文档https://developer.android.com/studio/command-line/variables.html,您应该更改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.

在修改或设置ANDROID_AVD_HOME后,你必须将所有内容移动到~user/。Android /avd/到你的新位置,并改变路径到每个模拟器的ini文件,只需用你的新路径替换它

其他回答

ANDROID_SDK_HOME在Windows 8 x64上也适用 也找到所有的位置(在我的情况下,它是d:\.android)并删除它。你不再需要它了。

我认为最简单的方法是从C:\Users[USER]移动avd文件夹。然后在C:\Users[USER]中创建一个指向它的符号链接。Android同名。

如果你想知道如何做到这一点,首先安装链接外壳扩展。在文件夹移动后,右键单击它,选择选择链接源,然后右键单击。android文件夹,然后在Drop As…子菜单选择符号链接。

我关注了https://www.mysysadmintips.com/windows/clients/761-move-android-studio-avd-folder-to-a-new-location。

Start copying a folder "C:\Users\user\.android\avd" to "D:\Android\.android\avd" (or something else). Close Android Studio and running emulators. Press Win + Break and open Advanced System Settings. Then press Environment Variables. Add a user variable ANDROID_SDK_HOME. (I didn't experiment with ANDROID_AVD_HOME.) In Variable value field write D:\Android. If you also moved SDK to another folder, change ANDROID_HOME (I forgot to change it and some emulators didn't launch, see https://stackoverflow.com/a/57408085/2914140). Wait until the folder will finish copying and start Android Studio. Open Android Virtual Device Manager and see a list of emulators. If you don't see emulators and they existed, then probably you entered wrong path into user variable value in step 3. In this case close AS, change the variable and open AS again. Start any emulator. It will try to restore it's state, but it sometimes fails. A black screen can appear instead of Android wallpaper. In this case you can: a. Restart your emulator. To do this close running emulator, then in AVD Manager click Cold Boot Now.

b.如果这没有帮助,打开模拟器设置,在文件“D:\Android\. Android\ avd\Pixel_API_27.ini”中找到。

更改路径到一个新的AVD文件夹。重新启动模拟器。

删除旧的AVD文件夹从“C:\Users\user\.android\ AVD”

根据官方文档https://developer.android.com/studio/command-line/variables.html,您应该更改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.

在修改或设置ANDROID_AVD_HOME后,你必须将所有内容移动到~user/。Android /avd/到你的新位置,并改变路径到每个模拟器的ini文件,只需用你的新路径替换它

修改“C:\Documents and Settings{your windows login}.android\avd\”中的“virtual_android2.2.ini”文件:

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

移动文件夹virtual_android2.2。从“C:\文档和设置{您的windows登录}。android\avd\变成E:\android_workspace\avd\。