我已经在运行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 tools目录下的Android .bat可能会导致问题。

如果你这样做,为了合法地将你的. Android目录定位到一个非默认位置,那么Android Studio列出的AVD(使用“Tools > Android > AVD管理器”)和sdk命令行工具“Android AVD”列出的AVD之间可能存在不一致。

我认为Android Studio,其内部AVD管理器,不使用Android .bat修改路径;它依赖ANDROID_SDK_HOME变量来定位avd。

我自己的测试表明,Android工具正确地使用ANDROID_SDK_HOME变量。

因此,就我所知,修改android.bat没有任何意义,使用环境变量应该是首选。

移动你的。android到任何你想要的地方。

然后,创建一个像这样的符号链接:

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

这只是告诉Linux无论何时路径~/。Android被任何应用程序引用,链接到/path/to/. Android。

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

环境变量ANDROID_AVD_HOME可以用来定义AVD管理器查找AVD INI文件的目录,因此可以用来改变虚拟设备的位置;

默认值为%USERPROFILE%\。android\avd在Windows(或~/。Linux上的android/avd)。

也可以为整个目录%USERPROFILE%\创建一个链接。Windows上的android(或目录~/的符号链接)。Linux上的android)。

移动AVD时,AVD INI文件中的路径条目需要相应更新。

主要有4个步骤 1. 复制。Android文件夹到你想要的位置,就像我在D:\Android\.android中做的那样 2. 在环境变量ANDROID_AVD_HOME D:\Android\.android\avd中设置ANDROID_AVD_HOME 3.更改avd name.ini文件内容的新位置,如 avd.ini.encoding = utf - 8 路径= D: \安卓\ .android \ avd \ Pixel_2_API_29.avd path.rel = avd \ Pixel_2_API_29.avd 目标= android-29 4. 重启android studio