windows 当设备在我的用户目录中时,为什么 Android 模拟器报告“未知的虚拟设备”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3384070/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 14:56:43  来源:igfitidea点击:

Why does the Android emulator report "unknown virtual device", when the device is in my user directory?

androidwindowsandroid-emulator

提问by Anthony Mastrean

I installed all the prerequisites for Android development. I created a virtual device through Eclipse and tried to run the Hello World sample application in that device. I received the following error message.

我安装了 Android 开发的所有先决条件。我通过 Eclipse 创建了一个虚拟设备,并尝试在该设备中运行 Hello World 示例应用程序。我收到以下错误消息。

emulator: ERROR: unknown virtual device name: 'Android21Device'
emulator: could not find virtual device named 'Android21Device'

模拟器:错误:未知虚拟设备名称:“Android21Device”
模拟器:找不到名为“Android21Device”的虚拟设备

I get the same error when I try to start the device from the command line and through the SDK program.

当我尝试从命令行和 SDK 程序启动设备时,我遇到了同样的错误。

I can see the device directory and files at

我可以在以下位置看到设备目录和文件

D:\Users\anthony\.android\avd\Android21Device.avd

D:\Users\anthony\.android\avd\Android21Device.avd

回答by Anthony Mastrean

Android Virtual Device Tool

安卓虚拟设备工具

The Virtual Device tool in the SDK Manager creates virtual devices in your user profile directory... in this case a secondary drive

SDK 管理器中的虚拟设备工具在您的用户配置文件目录中创建虚拟设备......在这种情况下是辅助驱动器

D:\Users\anthony\.android

D:\Users\anthony\.android

But, the emulator tries to load virtual device images from the system drive

但是,模拟器尝试从系统驱动器加载虚拟设备映像

C:\Users\anthony\.android

C:\Users\anthony\.android

Directory Junction

目录连接

There are two workarounds. First, you can create a directory hard-link (or junction)from the system drive android folder to the one in your user profile. In Windows 7, you can use the following command

有两种解决方法。首先,您可以创建一个从系统驱动器 android 文件夹到用户配置文件中的目录硬链接(或连接)。在 Windows 7 中,您可以使用以下命令

mklink /J C:\Users\anthony\.android D:\Users\anthony\.android

mklink /J C:\Users\anthony\.android D:\Users\anthony\.android

Android Home

安卓首页

The Android SDK Manager and emulator can use an environment variableANDROID_SDK_HOMEto identify the location of the .androiddirectory. Set a user or environment variable

Android SDK 管理器和模拟器可以使用环境变量ANDROID_SDK_HOME来标识.android目录的位置。设置用户或环境变量

ANDROID_SDK_HOME = 'D:\Users\anthony'

ANDROID_SDK_HOME = 'D:\Users\anthony'

回答by inri

If you find:

如果你发现:

emulator: ERROR: unknown virtual device name: 'Android21Device'
emulator: could not find virtual device named 'Android21Device'`

模拟器:错误:未知虚拟设备名称:“Android21Device”
模拟器:找不到名为“Android21Device”的虚拟设备

Just change your environment variables in the path in which your .android is found.

只需在找到 .android 的路径中更改环境变量即可。

  1. create your avd name such as hello in android sdk and avd manager
  2. start launch then if you find the error like above
  3. open the details
  4. see the path and copy the path example of path C:\Users\\Contacts.android\avd\hello.avd
  5. open your variable environment by start->computer>right click>properties>advance system setting>variable environment> system variable>
  6. see in the system variable where the variable is PATH then edit
  7. click the variable value then add the C:\Users\\Contacts.android\avd\hello.avd preceded by a semicolon(;). For example: C:\Program Files\Java\jdk1.6.0_21\bin;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Users\<something>\Contacts\.android\avd\hello.avd
  8. ok.then restart your computer...
  9. open eclipse then start your avd again...
  1. 在 android sdk 和 avd manager 中创建您的 avd 名称,例如 hello
  2. 如果您发现上述错误,则开始启动
  3. 打开详情
  4. 查看路径并复制路径示例 C:\Users\\Contacts.android\avd\hello.avd
  5. 通过开始->计算机>右键单击>属性>高级系统设置>变量环境>系统变量>打开您的变量环境
  6. 在系统变量中看到变量是 PATH 然后编辑
  7. 单击变量值,然后添加以分号 (;) 开头的 C:\Users\\Contacts.android\avd\hello.avd。例如:C:\Program Files\Java\jdk1.6.0_21\bin;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Users\<something>\Contacts\.android\avd\hello.avd
  8. 好的,然后重新启动您的计算机...
  9. 打开 eclipse 然后再次启动你的 avd ......

回答by Chetan Bhatt

You need to restart eclipse after closing it. File -> Restart will not help.

关闭后需要重新启动eclipse。文件 -> 重新启动将无济于事。

回答by Dinesh Prajapati

I was also getting the same Error and My resolution is below

我也遇到了同样的错误,我的解决方案如下

  1. Setting the ANDROID_SDK_HOME----Not worked for me
  2. Creating Directory Junction-----Not worked
  3. Now I went to the .android folder which has been created in some other location, open the avd and .ini file of the avd and edited it with the patch which system wants i.e "C:\Users\.android" and this worked for me :) yupiiii
  1. 设置 ANDROID_SDK_HOME----对我不起作用
  2. 创建目录连接-----不起作用
  3. 现在我转到在其他位置创建的 .android 文件夹,打开 avd 的 avd 和 .ini 文件,并使用系统想要的补丁对其进行编辑,即“C:\Users\.android”,这适用于我 :) yupiiii