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


当前回答

看看这个。 使用android命令创建avd,您可以指定文件放置的位置。

-p --path     Location path of the directory where the new AVD will be created

其他回答

请注意:根据之前的回答,修改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没有任何意义,使用环境变量应该是首选。

我关注了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”

看看这个。 使用android命令创建avd,您可以指定文件放置的位置。

-p --path     Location path of the directory where the new AVD will be created

用于Windows 10上的Visual Studio 2017

复制C:\Users\ YOURUSERNAME \。android文件夹到(例如)E:\avd

打开环境变量窗口:

进入设置,点击系统。 2 .在界面左侧单击“关于”,在界面右侧选择“系统信息” 底部。 在新窗口中,单击“Advanced system” 左边的设置。 点击环境变量 结果窗口的底部。

添加一个新变量:

变量名:ANDROID_SDK_HOME 变量值:一个目录的路径(例如E:\avd)

不要在变量值中包含.android。

重新启动Visual Studio。

更改SDK和NDK位置到:

工具->选项-> Xamarin -> Android设置

您可以更改新AVD的.ini文件:

target=android-7
path=C:\Users\username\.android\avd\VIRTUAL_DEVICE_NAME.avd

我不知道如何指定。ini文件应该存储在哪里:)