可以更改 Android 虚拟设备的保存位置吗?

发布于 2024-09-01 08:22:58 字数 201 浏览 3 评论 0原文

我已经在运行 Windows XP 的计算机上设置了 Android SDK 和 Eclipse,并且 AVD(Android 虚拟设备)默认保存到“Doc​​uments and Settings\user\.android”。有什么办法可以改变这种行为吗?我将所有其他组件保存在单独分区的目录中,并且希望合并所有内容。显然这没什么大不了的,但这里有人知道解决方法吗?

I've set up the Android SDK and Eclipse on my machine running Windows XP and AVDs (Android Virtual Devices) are saved to "Documents and Settings\user\.android" by default. Is there any way to change this behavior? I have all of the other components saved in a directory on a separate partition and would like everything to be consolidated. Obviously not a huge deal but does anyone here know a workaround for this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(23

面如桃花 2024-09-08 08:22:59

根据 https://developer.android.com/studio/command-line/ Variables.html,ANDROID_AVD_HOME 是正确的。

但是,由于某种未知的原因,在用户或系统级别设置环境变量后它不起作用。我尝试使用java代码System.getenv('ANDROID_AVD_HOME'),java没有读取新的环境变量。

解决方法是修改 studio64.exe.vmoptions(或 studio.exe.vmoptions)并添加 -DANDROID_AVD_HOME=D:\ANDROID\avd。

According to https://developer.android.com/studio/command-line/variables.html, ANDROID_AVD_HOME is correct.

However, for some unknown reason, it's not working after setting the environment variable at either user or system level. I tried with java code System.getenv('ANDROID_AVD_HOME'), the new environment variable was not being read by java.

A workaround is to modify studio64.exe.vmoptions (or studio.exe.vmoptions) and add -DANDROID_AVD_HOME=D:\ANDROID\avd.

另类 2024-09-08 08:22:58

添加新的用户环境变量(Windows 7):

  1. 开始菜单>控制面板>系统>高级系统设置(左侧)>环境变量
  2. 添加一个新的用户变量(在顶部),该变量指向您的主用户目录:

    <块引用>

    变量名称:ANDROID_SDK_HOME
    变量值:
    您选择的目录的路径

AVD Manager 将使用此目录将其 .android 目录保存到其中。

对于那些可能感兴趣的人,我在博客中介绍了我第一次涉足 Android 开发...
Android“Hello World”:一个悲惨的故事< /a>

或者,您可以使用快速环境编辑器来设置环境变量。

Add a new user environment variable (Windows 7):

  1. Start Menu > Control Panel > System > Advanced System Settings (on the left) > Environment Variables
  2. Add a new user variable (at the top) that points your home user directory:

    Variable name: ANDROID_SDK_HOME
    Variable value:
    a path to a directory of your choice

AVD Manager will use this directory to save its .android directory into it.

For those who may be interested, I blogged about my first foray into Android development...
Android "Hello World": a Tale of Woe

Alternatively, you can use the Rapid Environment Editor to set the environment variables.

來不及說愛妳 2024-09-08 08:22:58

基于官方文档 https://developer.android.com/studio/command-line /variables.html 您应该更改 ANDROID_AVD_HOME 环境变量:

模拟器环境变量

默认情况下,模拟器将配置文件存储在
$HOME/.android/ 和 $HOME/.android/avd/ 下的 AVD 数据。你可以
通过设置以下环境变量来覆盖默认值。
emulator -avd 命令搜索 avd 目录
$ANDROID_AVD_HOME 中的值的顺序,
$ANDROID_SDK_HOME/.android/avd/ 和 $HOME/.android/avd/。对于模拟器
环境变量帮助,在以下位置键入 emulator -help-environment
命令行。有关模拟器命令行选项的信息,请参阅
从命令行控制模拟器。

  • ANDROID_EMULATOR_HOME:设置用户特定模拟器配置目录的路径。默认位置是
    $ANDROID_SDK_HOME/.android/。
  • ANDROID_AVD_HOME:设置包含所有 AVD 特定文件的目录路径,这些文件大多由非常大的文件组成
    磁盘映像。默认位置是 $ANDROID_EMULATOR_HOME/avd/。
    如果默认位置是,您可能需要指定一个新位置
    磁盘空间不足。

更改或设置 ANDROID_AVD_HOME 后,您必须将 ~user/.android/avd/ 中的所有内容移动到新位置,并将路径更改为每个模拟器的 ini 文件,只需将其替换为您的新路径

Based on official documentation https://developer.android.com/studio/command-line/variables.html you should change 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.

After change or set ANDROID_AVD_HOME you will have to move all content inside ~user/.android/avd/ to your new location and change path into ini file of each emulator, just replace it with your new path

栩栩如生 2024-09-08 08:22:58

修改“C:\Documents and Settings{您的Windows登录名}.android\avd\”中的文件“virtual_android2.2.ini”:

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

并将文件夹“virtual_android2.2.avd”从“C:\Documents and Settings{您的 Windows 登录名}.android\avd\”进入“E:\android_workspace\avd\”。

Modify the file "virtual_android2.2.ini" in "C:\Documents and Settings{your windows login}.android\avd\":

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

And move the folder "virtual_android2.2.avd" from "C:\Documents and Settings{your windows login}.android\avd\" into "E:\android_workspace\avd\".

哀由 2024-09-08 08:22:58

将您的 .android 移动到您想要的任何位置。

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

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

这只是告诉 Linux,每当任何应用程序引用路径 ~/.android 时,都将其链接到 /path/to/.android

Move your .android to wherever you want it to.

Then, create a symlink like this:

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

This simply tells Linux that whenever the path ~/.android is referenced by any application, link it to /path/to/.android.

挽手叙旧 2024-09-08 08:22:58

转到 Android 工具目录。编辑 android.bat 命令文件。在命令文件的末尾处,找到类似于以下内容的行

call %java_exe% -Djava.ext.dirs=%java_ext_dirs% -Dcom.android.sdkmanager.toolsdir="%tools_dir%" -Dcom.android.sdkmanager.workdir="%work_dir%" -jar %jar_path% %*

并替换

call %java_exe%

call %java_exe% -Duser.home={your_prefer_dir}

其中 {your_prefer_dire} 是您的首选目录,不带大括号但添加双引号,

例如

call %java_exe% -Duser.home="E:\Program Files (x86)\android-sdk-windows"

Go to the Android tools directory. Edit the android.bat command file. At about the end of the command file, find a line similar to

call %java_exe% -Djava.ext.dirs=%java_ext_dirs% -Dcom.android.sdkmanager.toolsdir="%tools_dir%" -Dcom.android.sdkmanager.workdir="%work_dir%" -jar %jar_path% %*

and replace

call %java_exe%

with

call %java_exe% -Duser.home={your_prefer_dir}

where {your_prefer_dire} is your preferred directory without braces but add doublequotes,

e.g.

call %java_exe% -Duser.home="E:\Program Files (x86)\android-sdk-windows"
黯然 2024-09-08 08:22:58

对于 Windows 10 上的 Visual Studio 2017

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

打开环境变量窗口:

  1. 进入“设置”并单击“系统”。
  2. 单击左侧的“关于”,然后选择“系统信息”
    底部。
  3. 在新窗口中,单击“高级系统”
    左侧的设置。
  4. 单击环境变量
    结果窗口的底部。

添加新变量:

  • 变量名称:ANDROID_SDK_HOME
  • 变量值:目录路径(例如 E:\avd

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

重新启动 Visual Studio。

对于更改SDK & NDK 位置转到:

工具->选项-> Xamarin->安卓设置

For Visual Studio 2017 on Windows 10

Copy C:\Users\YOURUSERNAME\.android folder to (for example) E:\avd

Open the environment variables window:

  1. Go into Settings and click on System.
  2. On the left, click About and select System info at the
    bottom.
  3. In the new window, click Advanced system
    settings on the left.
  4. Click Environment Variables at
    the bottom of the resulting window.

Add a new variable:

  • Variable name: ANDROID_SDK_HOME
  • Variable value: a path to a directory (e.g E:\avd)

Don't include .android in the variable value.

Restart Visual Studio.

For change SDK & NDK location go to:

Tools -> Options -> Xamarin -> Android Setting

太阳公公是暖光 2024-09-08 08:22:58

在 Windows 10 中,我遇到了这个问题,因为我的 C 驱动器已满,我需要可用空间,AVD 文件夹有 14 GB 空间,所以我需要将该文件夹移动到另一个驱动程序,第一个答案对我不起作用,所以我测试了另一种方法解决这个问题,
如果您遇到同样的问题,我为您制作一张图片,您不需要将 .android 文件夹中的所有文件移动到另一个驱动器(这种方式不起作用)只需将 ....android\avd 中的 avd 文件夹移动到另一个驱动器并打开 .ini 文件并将 avd 文件夹路径从该文件更改为新路径。
就像这张图片:

“图像帮助您了解如何将旧路径更改为新路径”"

我希望这对您有用。

注意:请注意 ini 文件中路径前后的单独字符,您看不到该字符,如果删除该字符则不起作用

In Windows 10 I had that problem because My C Drive was getting full and I had needed free Space, AVD folder had 14 gig space so I needed to move that folder to another driver, first answer not work for Me so I tested another way to fix it this problem,
I make a picture for you if you have the same problem, you don't need to move all of the files in .android folder to another drive (this way not work) just move avd folders in ....android\avd to another drive and open .ini files and change avd folder path from that file to the new path.
Like this image:

image help you to see how to change old path to new path

I hope this works for you.

Note: careful about a separate character before and after the path in ini file that you cannot see,if you remove that character it's not works

落叶缤纷 2024-09-08 08:22:58

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

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

Check this out.
using the android command to create avd you can specify where to place files.

-p --path     Location path of the directory where the new AVD will be created
爱要勇敢去追 2024-09-08 08:22:58

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

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

我不知道如何指定 .ini 文件的存储位置:)

You can change the .ini file for the new AVD:

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

I don't know how to specify where the .ini file should be stored :)

因为看清所以看轻 2024-09-08 08:22:58

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

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

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

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

The environmental variable ANDROID_AVD_HOME can be used to define the directory in which the AVD Manager shall look for AVD INI files and can therefore be used to change the location of the virtual devices;

The default value is %USERPROFILE%\.android\avd on Windows (or ~/.android/avd on Linux).

One can also create a link for the whole directory %USERPROFILE%\.android on Windows (or a sym-link for directory ~/.android on Linux).

When moving AVDs, the path entry in AVD INI file needs to be updated accordingly.

淡墨 2024-09-08 08:22:58

1 - 将 AVD 移至新文件夹

2 - 开始菜单 >控制面板>系统>高级系统设置(左侧)>环境变量
添加新的用户变量:
变量名称:ANDROID_AVD_HOME
变量值:您选择的目录的路径

3 - 更改文件 .INI 设置新文件夹。

4 - 打开 Android Studio

WORKS - Windows 2010

更多说明:https://developer.android。 com/studio/命令行/变量

1 - Move AVD to new Folder

2 - start Menu > Control Panel > System > Advanced System Settings (on the left) > Environment Variables
Add a new user variable:
Variable name: ANDROID_AVD_HOME
Variable value: a path to a directory of your choice

3 - Change the file .INI Set new folder.

4 - Open Android Studio

WORKS - Windows 2010

MORE INSTRUCTIONS : https://developer.android.com/studio/command-line/variables

oО清风挽发oО 2024-09-08 08:22:58

指定 ANDROID_SDK_HOME 而不弄乱环境变量的另一种方法(特别是在使用 ec2 时)是简单地创建 eclipse 的快捷方式并将以下内容添加为目标

C:\Windows\System32\cmd.exe /C "setx ANDROID_SDK_HOME 您的 AVD 路径 /M & 您的 ECLIPSE.EXE 路径

这将在您启动 eclipse 时将 ANDROID_SDK_HOME 设置为系统变量。

华泰
保罗

Another way to specify ANDROID_SDK_HOME without messing around with environment variables (especially when using ec2) is simply create a shortcut of eclipse and add the following as target

C:\Windows\System32\cmd.exe /C "setx ANDROID_SDK_HOME YOUR AVD PATH /M & YOUR ECLIPSE.EXE PATH"

This will set ANDROID_SDK_HOME as system variable whenever you launch eclipse.

HTH
Paul

◇流星雨 2024-09-08 08:22:58

就我而言,我关心的是 C: 驱动器磁盘空间。
所以我所做的是将“.avd”文件夹(不是文件)复制到其他驱动器,并将“.ini”文件留在那里,但将其更改为指向移动的位置

In my case, what I concerned about is the C: drive disk space.
So what I did is copy the ".avd" folder(not file) to other drive, and leave the ".ini" file there but change it to point to the moved

踏月而来 2024-09-08 08:22:58

请注意以下事项:按照之前的答案中的建议修改 Android 工具目录中的 android.bat 可能会导致问题。

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

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

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

因此,据我所知,修改android.bat是没有意义的,应该优先使用环境变量。

Please take note of the following : modifying android.bat in the Android tools directory, as suggested in a previous answer, may lead to problems.

If you do so, in order to legitimately have your .android directory located to a non-default location then there may be an inconsistency between the AVDs listed by Android Studio (using "Tools > Android > AVD Manager") and the AVDs listed by sdk command line tool "android avd".

I suppose that Android Studio, with its internal AVD Manager, does not use the android.bat modified path ; it relies on the ANDROID_SDK_HOME variable to locate AVDs.

My own tests have shown that Android tools correctly use the ANDROID_SDK_HOME variable.

Therefore, there is no point, as far as I know, in modifying android.bat, and using the environment variable should be preferred.

欢你一世 2024-09-08 08:22:58

主要有4个步骤
1. 将 .android 文件夹复制到您想要的位置,就像我在 D:\Android\.android 中所做的那样
2. 在环境变量中设置ANDROID_AVD_HOME,例如 ANDROID_AVD_HOME D:\Android\.android\avd
3. 使用新位置更改 avd name.ini 文件内容,例如
avd.ini.encoding=UTF-8
路径=D:\Android\.android\avd\Pixel_2_API_29.avd
路径.rel=avd\Pixel_2_API_29.avd
目标=android-29

4.重启android studio

there are major 4 steps
1. copy the .android folder to your desired location as i did in D:\Android\.android
2. set ANDROID_AVD_HOME in environment variables like ANDROID_AVD_HOME D:\Android\.android\avd
3. change avd name.ini file contents with new location like
avd.ini.encoding=UTF-8
path=D:\Android\.android\avd\Pixel_2_API_29.avd
path.rel=avd\Pixel_2_API_29.avd
target=android-29

4. restart android studio

全部不再 2024-09-08 08:22:58

我认为最简单的方法是将 avd 文件夹从 C:\Users[USER].android 文件夹 移动到您想要的位置,然后在 中创建指向它的符号链接>C:\Users[USER].android 具有相同的名称。

如果您想知道如何执行此操作,请首先安装Link Shell 扩展。文件夹移动后右键单击它并选择选择链接源,然后右键单击.android文件夹并在Drop As...子菜单中选择符号链接强>。

I think the easiest way is to move the avd folder from C:\Users[USER].android folder to your desired location then create a symbolic link to it in C:\Users[USER].android with the same name.

If you wonder how to do this, first install Link Shell Extension. After folder movement right click on it and select Pick Link Source then right click in .android folder and in Drop As... sub menu select Symbolic Link.

韵柒 2024-09-08 08:22:58

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

  1. 开始将文件夹“C:\Users\user\.android\avd”复制到“D:\Android\.android\avd”(或其他文件夹)。

  2. 关闭 Android Studio 并运行模拟器。

  3. Win + Break并打开高级系统设置。然后按环境变量。添加用户变量 ANDROID_SDK_HOME。 (我没有尝试使用 ANDROID_AVD_HOME。)在 Variable value 字段中写入 D:\Android。如果您还将 SDK 移至另一个文件夹,请更改 ANDROID_HOME (我忘记更改它并且某些模拟器未启动,请参阅 https://stackoverflow.com/a/57408085/2914140)。

  4. 等待文件夹完成复制并启动 Android Studio。

  5. 打开 Android Virtual Device Manager 并查看模拟器列表。如果您没有看到模拟器并且它们存在,那么您可能在步骤 3 中在用户变量值中输入了错误的路径。在这种情况下,请关闭 AS,更改变量并再次打开 AS。

  6. 启动任何模拟器。它会尝试恢复其状态,但有时会失败。可能会出现黑屏而不是 Android 壁纸。

  7. 在这种情况下,您可以:

    a.重新启动您的模拟器。要执行此操作,请关闭正在运行的模拟器,然后在 AVD Manager 中单击立即冷启动

输入图片此处描述

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

输入图片此处说明

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

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

I followed https://www.mysysadmintips.com/windows/clients/761-move-android-studio-avd-folder-to-a-new-location.

  1. Start copying a folder "C:\Users\user\.android\avd" to "D:\Android\.android\avd" (or something else).

  2. Close Android Studio and running emulators.

  3. 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).

  4. Wait until the folder will finish copying and start Android Studio.

  5. 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.

  6. Start any emulator. It will try to restore it's state, but it sometimes fails. A black screen can appear instead of Android wallpaper.

  7. In this case you can:

    a. Restart your emulator. To do this close running emulator, then in AVD Manager click Cold Boot Now.

enter image description here

b. If this didn't help, open emulator settings, found in file "D:\Android\.android\avd\Pixel_API_27.ini".

enter image description here

Change a path to a new AVD folder. Restart the emulator.

  1. Delete old AVD folder from "C:\Users\user\.android\avd".
默嘫て 2024-09-08 08:22:58

对于 Windows 10:
ANDROID_SDK_HOME

此链接帮助了我。

然后将“avd”的所有内容移动到新位置。现在,您可能需要将每个avds的configurationSetting文件中的“path=”值更改为新位置。您可以在 Android Studio 的 avd manager 中看到旧的 avd,它们可以正常工作。

For Windows 10 :
ANDROID_SDK_HOME

this link helped me.

Then just moved all content of "avd" to the new location. Now you may need to change the value of "path=" in the configuration Setting file of each avds to the new location. You can see the old avds in avd manager in Android Studio and they work.

智商已欠费 2024-09-08 08:22:58

ANDROID_SDK_HOME 也在 Windows 8 x64 上为我工作
还找到所有位置(在我的例子中是 d:\.android)并将其删除。你将不再需要它了。

ANDROID_SDK_HOME also worked for me on Windows 8 x64
also find all location (in my case it was d:\.android) and delete it. You won't need it anymore.

完美的未来在梦里 2024-09-08 08:22:58

在 AVD 管理器中,使用带有 Google API 的目标设置 AVD 后,运行时出现错误。

详细信息显示:“AVD 未知目标 'Google Inc.:Google API:......”

在安装过程中(在 Win7 系统上)我选择了 SDK 目录位置,而不是接受 C:\Users\.. .
然后我将该目录添加到环境变量'path'
命令行:android 列表目标确实显示了一些 Google api。

ANDROID_SDK_HOME 设置为我的安装路径修复了 avd 运行错误。

In AVD manager, after setting up AVD using a target with Google APIs, on run was getting error.

Detail showed: "AVD Unknown target 'Google Inc.:Google APIs:...... "

During install (on Win7 system) I had chosen a SDK directory location, instead of accepting C:\Users\...
I'd then added that directory to environment variable 'path'
Command line: android list targets did show a couple of Google apis.

Setting ANDROID_SDK_HOME to my install path fixed the avd run error.

自我难过 2024-09-08 08:22:58

变量名称:ANDROID_SDK_HOME
变量值:C:\Users>用户名

对我有用。

Variable name: ANDROID_SDK_HOME
Variable value: C:\Users>User Name

worked for me.

偷得浮生 2024-09-08 08:22:58

MacO
获取目录 adv,

./emulator -help-datadir

默认目录是:

/Users/{your_computer_user_name}/.android

然后转到 avd 文件夹,编辑 .ini 文件,其中包含自定义模拟器目录的路径
例子 :

路径=/Volumes/Macintos/_emulatorandroid/avd/Nexus_5X_API_27.avd
路径.rel=avd/Nexus_5X_API_27.avd
目标=android-27

然后保存。现在您的模拟器已更改

在此处输入图像描述

结果:

在此处输入图像描述

MacOs
Get a directory adv

./emulator -help-datadir

the default directory is:

/Users/{your_computer_user_name}/.android

and then Go to avd Folder edit .ini file with path to your custom emulator directory
example :

path=/Volumes/Macintos/_emulatorandroid/avd/Nexus_5X_API_27.avd
path.rel=avd/Nexus_5X_API_27.avd
target=android-27

and then save. Now your Emulator haschange

enter image description here

And Result:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文