Quick Boot for Android Emulator in Practice

jughosta
4 min readDec 29, 2017

--

Recently a game changer was announced in Android Developers Blog — super fast boot for Android emulator. Less than 6 seconds and it’s ready to go.

How cool is that!

Quick Boot — Released as a stable feature today, Quick Boot allows you to resume your Android Emulator session in under 6 seconds.

The first time you start an Android Virtual Device (AVD) with the Android Emulator, it must perform a cold boot (just like powering on a device), but subsequent starts are fast and the system is restored to the state at which you closed the emulator last (similar to waking a device). [source]

This is how the first boot looks:

Cold Boot

“Saving state…” is happening on exit automatically:

Saving emulator state on exit to restore it next time in a few seconds

But… what to do if Android emulator stuck at some point and doesn’t react to any interactions? Close emulator and reopen it again? Not really. Only if you want to save a broken state…

Let’s find out how we can configure and smarter use Quick Boot feature with UI or the command line.

1. Update Android Studio/Emulator

This functionality is included in the newest version of Android Studio and enabled by default for your existing virtual devices and for new ones.

We accomplished this by completely re-engineering the legacy emulator snapshot architecture to work with virtual sensors and GPU acceleration. No additional setup is required because Quick Boot is enabled by default starting with Android Emulator v27.0.2. [source]

2. Configure emulator behaviour for a virtual device

Fortunately, there are some configuration options which we can manage.

  • In Android Virtual Device Manager if creating a new virtual device or editing an existing one (behind Advanced Settings button)
Boot options for a specific virtual device
  • In the command line

$ emulator -avd Virtual_Device_Name_API_26 [options]

-no-snapshot-save performs a quick boot if possible, but does not save the emulator state on exit. [source]

  • In extended settings for a running Android Emulator
Quick Boot configuration options

With option “Ask” on exit it will look like this:

A confirmation to save or not a current emulator state on exit

Once I had a case when Android emulator got frozen. I just exited the emulator in order to reboot it. I forgot that Quick Boot exist and it saved that unwanted state of my virtual device. Who cares if it does respond in my case? At least the boot was super fast! I love this feature.

So I needed to reboot my emulator without using a previous state. “How can I “unstuck” my emulator? Hm, I will disable Quick Boot feature for a while: close the emulator without saving the current state and reopen it to have a fresh new start! It will just do a cold boot, right? Easy!” I thought. Nope!

The configuration didn’t work as I expected. Quick Boot feature is so smart that it keeps the latest saved state from #1 (cold boot) … to #n (your last exit if enabled). As I already had a saved state #n, and even if on exit I declined saving the current state (#n+1), it boots to a previous saved state #n again. And why did I think that I could get a new #1? Never mind.

3. Reset/ignore a saved state

Alright. We can always ignore a saved state and reboot an emulator in UI or in the command line. Fresh start for my emulator!

  • In Android Virtual Device Manager
Cold Boot
  • In the command line

$ emulator -avd Virtual_Device_Name_API_26 [options]

-no-snapshot-load performs a cold boot, and saves the emulator state on exit.

-no-snapshot disables the Quick Boot feature completely—it does not load or save the emulator state. [source]

Conclusion

Thanks for Quick Boot feature! I really love it. Android emulator boots MUCH faster now!

Thanks for reading! 👍

PS. Less time on boot, more time on exit ;)

--

--