为什么安卓模拟器这么慢?我们如何加速Android模拟器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1554099/
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-08-20 03:14:46  来源:igfitidea点击:

Why is the Android emulator so slow? How can we speed up the Android emulator?

androidperformanceandroid-emulatorgenymotionqemu

提问by Andrie

I have got a 2.67  GHz Celeron processor, and 1.21  GB of RAM on a x86Windows XPProfessional machine.

我  在x86Windows XPProfessional 机器上有一个2.67  GHz Celeron 处理器和1.21GB RAM 。

My understanding is that the Android Emulatorshould start fairly quickly on such a machine, but for me, it does not. I have followed all the instructions in setting up the IDE, SDKs, JDKs and such and have had some success in starting the emulator quickly, but that is very rare. How can I, if possible, fix this problem?

我的理解是,Android 模拟器应该在这样的机器上很快启动,但对我来说,它没有。我遵循了设置 IDE、SDK、JDK 等的所有说明,并且在快速启动模拟器方面取得了一些成功,但这种情况非常罕见。如果可能,我该如何解决这个问题?

Even if it starts and loads the home screen, it is very sluggish. I have tried the Eclipse IDEin version 3.5(Galileo) and 3.4(Ganymede).

即使它启动并加载主屏幕,它也非常缓慢。我已经在3.5(Galileo) 和3.4(Ganymede)版本中尝试了Eclipse IDE

回答by Vikas Patidar

Update

更新

You can now enable the Quick Boot option for Android Emulator. That will save emulator state, and it will start the emulator quickly on the next boot.

您现在可以为 Android Emulator 启用快速启动选项。这将保存模拟器状态,并在下次启动时快速启动模拟器。

Click on Emulator edit button, then click Show Advanced Setting. Then enable Quick Bootlike below screenshot.

单击 Emulator 编辑按钮,然后单击Show Advanced Setting。然后Quick Boot像下面的截图一样启用。

Quick boot

快速启动

Android Development Tools (ADT) 9.0.0(or later) has a feature that allows you to save state of the AVD (emulator), and you can start your emulator instantly. You have to enable this feature while creating a new AVD or you can just create it later by editing the AVD.

Android Development Tools (ADT) 9.0.0(或更高版本)具有一项功能,可以让您保存 AVD(模拟器)的状态,并且您可以立即启动您的模拟器。您必须在创建新 AVD 时启用此功能,或者您可以稍后通过编辑 AVD 来创建它。

Also I have increased the Device RAM Sizeto 1024which results in a very fast emulator.

此外,我增加了Device RAM Size1024在一个非常快的模拟器,其结果。

Refer to the given below screenshots for more information.

有关更多信息,请参阅下面给出的屏幕截图。

Creating a new AVD with the save snapshot feature.

使用保存快照功能创建新的 AVD。

Android emulator with save snapshot feature.

具有保存快照功能的 Android 模拟器。

Launching the emulator from the snapshot.

从快照启动模拟器。

Launching the emulator from the snapshot.

从快照启动模拟器。

And for speeding up your emulator you can refer to Speed up your Android Emulator!:

对于加速您的模拟器,您可以参考加速您的 Android 模拟器!

回答by Prashanth Sams

IMPORTANT NOTE: Please firstrefer to the Intel list about VTto make sure your CPU supports Intel VT.

重要提示:请首先参考英特尔关于 VT 的列表,以确保您的 CPU 支持英特尔 VT。

HAXM Speeds Up the Slow Android Emulator

HAXM 加速了缓慢的 Android 模拟器

HAXMstands for - "Intel Hardware Accelerated Execution Manager"

HAXM代表 - “英特尔硬件加速执行管理器”

Currently, it supports only Intel? VT (Intel Virtualization Technology).

目前,它只支持英特尔?VT(英特尔虚拟化技术)。

The Android emulator is based on QEMU. The interface between QEMU and the HAXM driver on the host system is designed to be vendor-agnostic.

Android 模拟器基于QEMU。QEMU 和主机系统上的 HAXM 驱动程序之间的接口被设计为与供应商无关。

HAXM

HAXM

Steps for Configuring Your Android Development Environment for HAXM

为 HAXM 配置 Android 开发环境的步骤

  1. Update Eclipse: Make sure your Eclipse installation and the ADT plug-in are fully up-to-date.

  2. Update your Android Tools: After each Eclipse plug-in update, it is important to update your Android SDK Tools. To do this, launch the Android SDK Manager and update all the Android SDK components. To take advantage of HAXM, you must be on at least release version 17.

  1. 更新 Eclipse:确保您的 Eclipse 安装和 ADT 插件是完全最新的。

  2. 更新您的 Android 工具:在每次 Eclipse 插件更新后,更新您的 Android SDK 工具非常重要。为此,请启动 Android SDK Manager 并更新所有 Android SDK 组件。要利用 HAXM,您必须至少使用版本 17。

Enter image description here

在此处输入图片说明

  • Download the x86 Atom System Imagesand the Intel Hardware Accelerated Execution Manager Driver. Follow the image below:
  • 下载x86 Atom 系统映像英特尔硬件加速执行管理器驱动程序。按照下面的图片:

Enter image description here

在此处输入图片说明

  • Install the HAXM Driver by running "IntelHaxm.exe". It will be located in one of the following locations:

    • C:\Program Files\Android\android-sdk\extras\intel\Hardware_Accelerated_Execution_Manager

    • C:\Users\<user>\adt-bundle-windows-x86_64\sdk\extras\intel\Hardware_Accelerated_Execution_Manager

    If the installer fails with the message that Intel VT must be turned on, you need to enable this in the BIOS. See the description for how to do this in Enabling Intel VT (Virtualization Technology) .

  • 通过运行“IntelHaxm.exe”安装 HAXM 驱动程序。它将位于以下位置之一:

    • C:\Program Files\Android\android-sdk\extras\intel\Hardware_Accelerated_Execution_Manager

    • C:\Users\<user>\adt-bundle-windows-x86_64\sdk\extras\intel\Hardware_Accelerated_Execution_Manager

    如果安装程序失败并显示必须打开 Intel VT 的消息,您需要在BIOS 中启用它。请参阅启用 Intel VT(虚拟化技术)中有关如何执行此操作的说明。

Install .exe or .dmg

安装 .exe 或 .dmg

  • Create a newx86 AVD: Follow the image below:
  • 创建一个新的x86 AVD:按照下图操作:

Create AVD

创建 AVD

  • Or as for new SDK, Enter image description here
  • 或者对于新的SDK, 在此处输入图片说明

回答by Pehat

Try Android x86. It's much faster than the Google Android emulator. Follow these steps:

尝试Android x86。它比谷歌安卓模拟器快得多。按着这些次序:

  1. Install VirtualBox.
  2. Download the ISO filethat you need.
  3. Create a virtual machine as Linux 2.6/Other Linux, 512 MB RAM, HD 2 GB. Network: PCnet-Fast III, attached to NAT. You can also use a bridged adapter, but you need a DHCPserver in your environment.
  4. Install Android x86 on the emulator, run it.
  5. Press Alt+F1, type netcfg, remember the IP address, press Alt+F7.
  6. Run cmd on your Windows XP system, change the directory to your Android tools directory, type adb connect <virtual_machine_IP>.
  7. Start Eclipse, open the ADT plugin, find the device, and enjoy!
  1. 安装VirtualBox
  2. 下载您需要的ISO 文件
  3. 创建一个虚拟机为 Linux 2.6/Other Linux,512 MB RAM,HD 2 GB。网络:PCnet-Fast III,连接到NAT。您也可以使用桥接适配器,但您的环境中需要DHCP服务器。
  4. 在模拟器上安装 Android x86,运行它。
  5. Alt+ F1,输入netcfg,记住 IP 地址,按Alt+ F7
  6. 在您的 Windows XP 系统上运行 cmd,将目录更改为您的 Android 工具目录,键入adb connect <virtual_machine_IP>.
  7. 启动Eclipse,打开ADT插件,找到设备,尽情享受吧!

回答by blaffie

UPDATE:The latest version of Android studio (2.x) made major improvements to the bundled emulator. It's responsive and has a whole bunch of features.

更新:最新版本的 Android Studio (2.x) 对捆绑的模拟器进行了重大改进。它具有响应性并具有大量功能。

For those still interested: Try using Genymotion. You can download a version for Windows/Mac OS X/Linux after registering. A plugin for Eclipse is also available:

对于那些仍然感兴趣的人:尝试使用Genymotion。注册后,您可以下载适用于 Windows/Mac OS X/Linux 的版本。Eclipse 的插件也可用:

The installation of the plugin can be done by launching Eclipse and going to "Help / Install New Software" menu, then just add a new Update Site with the following URL: http://plugins.genymotion.com/eclipse. Follow the steps indicated by Eclipse.

插件的安装可以通过启动 Eclipse 并转到“帮助/安装新软件”菜单来完成,然后只需使用以下 URL 添加一个新的更新站点:http: //plugins.genymotion.com/eclipse。按照 Eclipse 指示的步骤进行操作。

This emulator is fast and responsive.

这个模拟器速度快,反应灵敏。

GenyMotion allows you to control various sensors of your device including the battery level, signal strength, and GPS. The latest version now also contains camera tools.

GenyMotion 允许您控制设备的各种传感器,包括电池电量、信号强度和 GPS。最新版本现在还包含相机工具。

回答by Nicolas Raoul

The emulator included in your (old) version of Eclipse is very slow.

您的(旧)Eclipse 版本中包含的模拟器非常慢。

Recent emulators are faster than they use to be in 2010. Update your SDK/IDE.

最近的模拟器比 2010 年的速度更快。更新您的 SDK/IDE。

Personally, I use a real phone to do my tests. It is faster and tests are more realistic. But if you want to test your application on a lot of different Android versions and don't want to buy several phones, you will have to use the emulator from time to time.

就个人而言,我使用真正的手机进行测试。它更快,测试更真实。但是如果您想在许多不同的 Android 版本上测试您的应用程序并且不想购买多部手机,您将不得不不时使用模拟器。

回答by Jay Askren

The startup of the emulator is very slow. The good thing is that you only need to start the emulator once. If the emulator is already running and you run your app again, the emulator reinstalls the app relatively quickly. Of course, if you want to know how fast it will run on a phone, it is best to test it on a real phone.

模拟器的启动很慢。好处是你只需要启动模拟器一次。如果模拟器已经在运行并且您再次运行您的应用程序,模拟器会相对较快地重新安装应用程序。当然,如果你想知道它在手机上的运行速度,最好在真机上进行测试。

回答by James Wald

Intel released recommended installation instructions for the ICS emulatoron May 15, 2012. This worked for me. The emulator is now fast and the UI is smooth.

英特尔于2012 年 5 月 15 日发布了 ICS 仿真器的推荐安装说明。这对我有用。模拟器现在速度很快,用户界面也很流畅。

The first half of the instructions are detailed enough, so I will assume you were able to install the Intel x86 Atom System Image(s) using the Android SDK manager, as well as Intel HAXM.

前半部分的说明已经足够详细,因此我假设您能够使用 Android SDK 管理器以及 Intel HAXM 安装 Intel x86 Atom System Image(s)。

Now to ensure that everything else is set up so you can enjoy a highly performing emulator:

现在确保设置其他所有内容,以便您可以享受高性能模拟器:

And start it:

并启动它:

sudo kextload -b com.intel.kext.intelhaxm (mac)

If HAXM is working properly, you may see this message when launching the emulator:

如果 HAXM 正常工作,您可能会在启动模拟器时看到此消息:

HAX is working and emulator runs in fast virtual mode

HAX 正在运行,模拟器在快速虚拟模式下运行

Otherwise, you may see this error:

否则,您可能会看到此错误:

HAX is not working and the emulator runs in emulation mode emulator:
Failed to open the hax module

HAX 不工作且仿真器在仿真模式下运行 仿真器:
无法打开 hax 模块

  • Use GPU emulation.You cannot use the Snapshot option when using GPU emulation as of this writing. Ensure that GPU emulation is set to "yes".

  • Set the device memory to 1024  MB or more, but not more than the Intel HAXM setting. I use 1024  MB per device and 2048 for HAXM.

  • 使用 GPU 模拟。在撰写本文时,在使用 GPU 仿真时无法使用快照选项。确保 GPU 模拟设置为“是”。

  • 将设备内存设置为 1024 MB 或更多,但不超过 Intel HAXM 设置。我为每个设备使用 1024 MB,为 HAXM 使用 2048 MB。

Always double-check the settings after saving!The emulator is very picky about what it allows you to set, and it will revert configurations without telling you.

保存后务必仔细检查设置!模拟器对它允许您设置的内容非常挑剔,它会在不告诉您的情况下恢复配置。

With these settings the software keyboard no longer appears, nor do the on-screen back, menu, and recent keys. This appears to be a limitation of the current ICS Intel x86 system image. You will need to use the keyboard shortcuts.

通过这些设置,软件键盘不再出现,屏幕上的返回、菜单和最近使用的键也不再出现。这似乎是当前 ICS Intel x86 系统映像的限制。您将需要使用键盘快捷键

On Mac OS you will need to hold fn+ controlfor the F1- F12keys to work. Page up/down/left/right can be performed using control + arrow keys.

在 Mac OS 上,您需要按住fn+键才能control使用F1-F12键。可以使用 control + 箭头键执行向上/向下/向左/向右翻页。

回答by andgps

You can create emulator.bat with following command to start the emulator. It will start faster.

您可以使用以下命令创建 emulator.bat 以启动模拟器。它会启动得更快。

emulator.exe -cpu-delay 0 -no-boot-anim @<avd name>

Or on Unix (Mac or Linux flavors):

或者在 Unix(Mac 或 Linux 版本)上:

emulator -cpu-delay 0 -no-boot-anim @<avd name>

回答by Fedor

I've noticed that the emulator starts much faster if there's no Dalvik Debug Monitor Server (DDMS) connected. So if you start the emulator from Virtual Device Manager "SDK Setup.exe" and Eclipse is not started, the emulator works faster.

我注意到如果没有连接 Dalvik Debug Monitor Server (DDMS),模拟器的启动速度会快得多。因此,如果您从虚拟设备管理器“SDK Setup.exe”启动模拟器并且 Eclipse 未启动,则模拟器运行速度会更快。

If you start the emulator from Eclipse: DDMS is there, so sometimes the emulator is extremely slow, but sometimes it's faster.

如果您从 Eclipse 启动模拟器:DDMS 在那里,所以有时模拟器非常慢,但有时会更快。

回答by JRE.exe

Emulators are slow. There's really nothing you can do about it, but there are alternatives to the emulator.

模拟器很慢。你真的无能为力,但有模拟器的替代品。

  1. Genymotion - Preferred

  2. VirtualBox

  3. BlueStacks

  4. YouWave

  5. Windows Android Emulator

  6. Jar of Beans

  7. Andy

  1. Genymotion - 首选

  2. 虚拟盒子

  3. 蓝叠

  4. 你挥手

  5. Windows 安卓模拟器

  6. 一罐豆子

  7. 安迪

To make your emulator faster, you can host a GPU and use a lighter Android version (Android 2.3(Gingerbread)). Developing on a Mac would be better. Why use an emulator, BTW? Using a real phone makes more sense.

为了使您的模拟器更快,您可以托管一个 GPU 并使用更轻的 Android 版本(Android 2.3(Gingerbread))。在 Mac 上开发会更好。为什么要使用模拟器,顺便说一句?使用真正的手机更有意义。