开发者

Way to pause the Android Emulator?

I do a lot of development on my laptop, and I use various Android Emulators to do it. When running, the emulator frequently takes up a large amount of my CPU, and consequently decreases my laptop's battery life significantly.

Is there a way to temporarily pause the emulator, or at least shut down whatever it is that's consuming all the unnece开发者_运维问答ssary cpu?

I know that with sdk r9 and later I can snapshot the emulator and quit/restart it fairly quickly, but I'm hoping for something even less invasive to my work flow than that.


In Linux you can stop the process by

$ killall --signal STOP emulator

or

$ killall --signal STOP emulator64-arm

At a later time continue by

$ killall --signal CONT emulator

or

$ killall --signal CONT emulator64-arm

Gotcha: If you update Eclipse, make sure the emulator is not stopped when restarting eclipse. Eclipse will stall when loading, waiting for the stopped emulator to continue.


The newest version of adt supports emulator snapshots, meaning you can just close the emulator and bring it back to where it was quickly. So to solve your problem simply close your emulator and restore it when you need it.

Check snapshot enabled when creating your avd:

Way to pause the Android Emulator?

Ensure launch and save snapshot are checked when launching:

Way to pause the Android Emulator?


For a cross-platform solution, this should pause and then resume execution of the emulator:

$ telnet localhost 5554  
> avd stop  
> avd start


On Mac OSX

Using Activity Monitor, find the Process ID # (PID) for your emulator.

Way to pause the Android Emulator?

To Stop

In Terminal telnet to your emulator:

telnet localhost 5554

Stop the emulator

avd stop

In another Terminal window, stop (pause) the process (19636 is an example PID, you'll need the particular PID for your emulator from Activity Monitor):

kill -STOP 19636

To Restart

To restart emulator, from the telnet connection to emulator:

avd start

Then finally continue the process from the OSX Terminal:

kill -CONT 19636

I found that simply doing kill -STOP/CONT would not allow the emulator to come back to life when trying to restart. After continuing the process, the emulator would remain frozen, although it's CPU usage returned to normal.

Stopping the emulator via telnet, then stopping the process then reversing these steps to restart, seemed to work flawlessly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜