可以更改 Android 虚拟设备的保存位置吗?
我已经在运行 Windows XP 的计算机上设置了 Android SDK 和 Eclipse,并且 AVD(Android 虚拟设备)默认保存到“Documents 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(23)
添加新的用户环境变量(Windows 7):
<块引用>
变量名称:ANDROID_SDK_HOME
变量值:
您选择的目录的路径
AVD Manager 将使用此目录将其
.android
目录保存到其中。对于那些可能感兴趣的人,我在博客中介绍了我第一次涉足 Android 开发...
Android“Hello World”:一个悲惨的故事< /a>
或者,您可以使用快速环境编辑器来设置环境变量。
Add a new user environment variable (Windows 7):
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.
基于官方文档 https://developer.android.com/studio/command-line /variables.html 您应该更改 ANDROID_AVD_HOME 环境变量:
更改或设置 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:
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
修改“C:\Documents and Settings{您的Windows登录}.android\avd\”中的文件“virtual_android2.2.ini”:
并将文件夹“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\":
And move the folder "virtual_android2.2.avd" from "C:\Documents and Settings{your windows login}.android\avd\" into "E:\android_workspace\avd\".
将您的
.android
移动到您想要的任何位置。然后,创建一个像这样的符号链接:
这只是告诉 Linux,每当任何应用程序引用路径 ~
/.android
时,都将其链接到/path/to/.android
。Move your
.android
to wherever you want it to.Then, create a symlink like this:
This simply tells Linux that whenever the path ~
/.android
is referenced by any application, link it to/path/to/.android
.转到 Android 工具目录。编辑 android.bat 命令文件。在命令文件的末尾处,找到类似于以下内容的行
并替换
为
其中 {your_prefer_dire} 是您的首选目录,不带大括号但添加双引号,
例如
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
and replace
with
where {your_prefer_dire} is your preferred directory without braces but add doublequotes,
e.g.
对于 Windows 10 上的 Visual Studio 2017
将
C:\Users\YOURUSERNAME\.android
文件夹复制到(例如)E:\avd
打开环境变量窗口:
底部。
左侧的设置。
结果窗口的底部。
添加新变量:
ANDROID_SDK_HOME
E:\avd
)不要包含
.android
在变量值中。重新启动 Visual Studio。
对于更改SDK & NDK 位置转到:
For Visual Studio 2017 on Windows 10
Copy
C:\Users\YOURUSERNAME\.android
folder to (for example)E:\avd
Open the environment variables window:
bottom.
settings on the left.
the bottom of the resulting window.
Add a new variable:
ANDROID_SDK_HOME
E:\avd
)Don't include
.android
in the variable value.Restart Visual Studio.
For change SDK & NDK location go to:
在 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:
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
检查这个。
使用
android
命令创建avd
您可以指定放置文件的位置。Check this out.
using the
android
command to createavd
you can specify where to place files.您可以更改新 AVD 的 .ini 文件:
我不知道如何指定 .ini 文件的存储位置:)
You can change the .ini file for the new AVD:
I don't know how to specify where the .ini file should be stored :)
环境变量 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.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
指定 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
就我而言,我关心的是 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
请注意以下事项:按照之前的答案中的建议修改 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.
主要有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
我认为最简单的方法是将 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.
我关注了 https: //www.mysysadmintips.com/windows/clients/761-move-android-studio-avd-folder-to-a-new-location。
开始将文件夹“C:\Users\user\.android\avd”复制到“D:\Android\.android\avd”(或其他文件夹)。
关闭 Android Studio 并运行模拟器。
按
Win + Break
并打开高级系统设置
。然后按环境变量
。添加用户变量ANDROID_SDK_HOME
。 (我没有尝试使用ANDROID_AVD_HOME
。)在Variable value
字段中写入D:\Android
。如果您还将 SDK 移至另一个文件夹,请更改ANDROID_HOME
(我忘记更改它并且某些模拟器未启动,请参阅 https://stackoverflow.com/a/57408085/2914140)。等待文件夹完成复制并启动 Android Studio。
打开
Android Virtual Device Manager
并查看模拟器列表。如果您没有看到模拟器并且它们存在,那么您可能在步骤 3 中在用户变量值中输入了错误的路径。在这种情况下,请关闭 AS,更改变量并再次打开 AS。启动任何模拟器。它会尝试恢复其状态,但有时会失败。可能会出现黑屏而不是 Android 壁纸。
在这种情况下,您可以:
a.重新启动您的模拟器。要执行此操作,请关闭正在运行的模拟器,然后在 AVD Manager 中单击
立即冷启动
。b.如果这没有帮助,请打开模拟器设置,可在文件“D:\Android\.android\avd\Pixel_API_27.ini”中找到。
更改新 AVD 文件夹的路径。重新启动模拟器。
I followed 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 openAdvanced System Settings
. Then pressEnvironment Variables
. Add a user variableANDROID_SDK_HOME
. (I didn't experiment withANDROID_AVD_HOME
.) InVariable value
field writeD:\Android
. If you also moved SDK to another folder, changeANDROID_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. If this didn't help, open emulator settings, found in file "D:\Android\.android\avd\Pixel_API_27.ini".
Change a path to a new AVD folder. Restart the emulator.
对于 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 theconfiguration Setting
file of each avds to the new location. You can see the old avds inavd manager
in Android Studio and they work.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.
在 AVD 管理器中,使用带有
Google API
的目标设置 AVD 后,运行时出现错误。在安装过程中(在 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.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.变量名称:ANDROID_SDK_HOME
变量值:C:\Users>用户名
对我有用。
Variable name: ANDROID_SDK_HOME
Variable value: C:\Users>User Name
worked for me.
MacO
获取目录 adv,
默认目录是:
然后转到 avd 文件夹,编辑 .ini 文件,其中包含自定义模拟器目录的路径
例子 :
然后保存。现在您的模拟器已更改
结果:
MacOs
Get a directory adv
the default directory is:
and then Go to avd Folder edit .ini file with path to your custom emulator directory
example :
and then save. Now your Emulator haschange
And Result:
根据 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.