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.
Asked
Active
Viewed 6,932 times
1 Answers
10
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
.
-
As @Chris pointed out in the comment above, the snapshots are a bit finicky. I have seen spontaneous reboots of the Android OS after loading a snapshot. – Claes Jun 05 '11 at 20:38
-
this doesnt work for me. I get "KO: unnown command, try 'help' is it still possible to get a snapshot of the emulator running API 23? – user3712476 Nov 09 '16 at 17:14
-
It seems to be available upto Tools 24 (= API 24), then it throws an error in Tools v25 to the tune of the capability is not supported, but in Tools v26, there is no error, so i suspect it might be available again, but I haven't got it working yet :-( – Irvin H. Apr 10 '17 at 14:02
-
... And Google seems to know about this. See their [Issue Tracker](https://code.google.com/p/android/issues/detail?id=231643&q=%22emulator%20console%22%20%20Subcomponent%3DTools-emulator%20opened-after%3A2016%2F1%2F1&sort=-id&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened) – Irvin H. Apr 10 '17 at 14:03