How do I take a snapshot of the Android emulator&#

2019-02-03 18:59发布

问题:

When I launch the Android emulator from the Android SDK and AVD Manager I can check the boxes Launch from snapshot and Save to snapshot so that the emulator's state is saved when I close it and restored again when I launch it. This is great because I don't have to wait for Android to boot each time the emulator is launched. However, I also want to take snapshots of the emulator's state during a session and later during the session revert back to the snapshot, for example to re-run my tests. How do I do this? There do not seem to be any controls for this in the AVD Manager.

回答1:

I found the answer thanks to this comment. To take and load snapshots, start a Telnet session to the emulator:

$ telnet localhost 5554
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Android Console: type 'help' for a list of commands
OK
avd snapshot save snapshot_name
OK
avd snapshot load snapshot_name
OK

The Android emulator freezes for a few seconds while saving/loading a snapshot. You can also list the snapshots using avd snapshot list.