Android模拟器有点迟钝。对于摩托罗拉Droid和Nexus One等设备,应用程序在实际设备上的运行速度比模拟器快。在测试游戏和视觉效果时,这是一个问题。

如何使模拟器尽可能快地运行?我一直在摆弄它的参数,但还没有发现一个配置显示出明显的改进。


当前回答

编辑虽然使用英特尔图像可以获得一些性能提升,但使用Genymotion获得的性能要大得多。请看保罗·拉默茨马的回答。

以前的回答

ADT rev 17模拟器支持在Windows和Mac OS x上以虚拟化模式运行x86系统映像,这对性能有显著影响。

ADT rev 17注释: http://android-developers.blogspot.jp/2012/03/updated-sdk-tools-and-adt-revision-17.html

配置虚拟机加速: http://developer.android.com/guide/developing/devices/emulator.html#accel-vm

其他回答

更新:现在Intel x86映像已经可用,最好的答案是上面的zest。

正如CommonsWare正确指出的那样,这个模拟器很慢,因为它模拟的是ARM CPU,而ARM CPU需要转换成Intel操作码。这种虚拟化占用CPU资源。

为了让模拟器更快,你必须给它更多的CPU。从快速CPU开始,如果可以的话升级。

然后,给模拟器更多的CPU:

Disable Hyperthreading - Since the emulator doesn't appear to utilize more than one core, hyperthreading actually reduces the amount of overall CPU time the emulator will get. Disabling HT will slow down apps that take advantage of multiple CPUs. Hyperthreading must be disabled in your BIOS. Make the emulator run on a CPU other than CPU 0 - This has a much smaller impact than turning off HT, but it helps some. On Windows, you can specify which CPU a process will run on. Many apps will chew up CPU 0, and by default the emulator runs on CPU 0. I change the emulator to run on the last one. Note that on OS X you cannot set affinity (see: https://superuser.com/questions/149312/how-to-set-processor-affinity-on-a-mac).

我看到在这两个改变到位后,大约有50%的改善。

在Windows 7上设置处理器亲和性:

打开任务管理器 单击“查看所有进程”(以管理员身份运行,否则无法设置处理器相关性) 右键单击模拟器.exe并选择设置亲缘性… 在Set Affinity对话框中,只选择最后一个CPU

注意:当您以这种方式更改关联时,它只在流程的生命周期内更改。下一次开始,你必须再来一次。

我建议让Genymotion转一转。它运行在Oracle的VirtualBox上,在一个中等的系统上可以达到60帧/秒。

下面是我的一个工作室的屏幕截图,运行在低端的2012款MacBook Air上:

如果你看不懂文字,这是一个以56.6帧/秒运行的Nexus 7模拟器。额外的(大!)奖励是谷歌播放和谷歌播放服务与虚拟机打包。

(演示动画的来源可以在这里找到。)

I think it is because clr virtual machine uses cpu directly without code opcode translation. It may be optimization for clr application or may be windows mobile/window phone 7 started on INTEL proccessor. Android platform based on linux and theoretically you can start android on virtual machine in i686 environment. In this case virtual machines such as vmware could execute some opcodes direcly. But this option will be allowed only if you write on the Java. Because the Java interpret their byte-code or precompile it before execution. see: http://www.taranfx.com/how-to-run-google-android-in-virtualbox-vmware-on-netbooks

你也可以尝试Visual Studio Android Emulator,它也可以作为一个独立的模拟器安装(你不需要Visual Studio)。请注意,它只能安装在Windows Pro或更高的系统上。

如果你没有一个好的显卡(像我一样),选择一个低分辨率的模拟器(例如:Nexus S)