I had a long standing issue where I could only launch two emulators on my Macbook Pro simultaneously. Any other emulators would launch and get a black screen and wouldn’t load. I accepted this as fact, and carried on with life.
Finally today I found the need to figure out “why” this was the case as I wanted to start sharding my Android UI tests to speed them up. I was given the suggestion that it could be the # of CPUs or the amount of RAM. If you look in the logs you may see something like this (if you launch the emulator from android avd
):
or you may see:
“HAXM does not have enough memory remaining to load this AVD.”
In order to change your memory allocation for HAXM, you need to re-install it, so run the installer again which is a DMG at: [$ANDROID_HOME/sdk/extras/intel/Hardware_Accelerated_Execution_Manager/ ] and this time select more memory. [HAXM Technical Docs]
But… before you install, make sure you have the latest version. The latest version as of September 7th, 2016 is 6.0.3 (Which was released on June 21, 2016).
On my Macbook, I was given 2048MB of memory by default which allowed me to run 2 emulators simultaneously (as seen above).
I have 16GB total memory though, so lets make it so I can run a bunch of emulators at once by allocating 8GB 🙂
Here is my Macbook Pro running 6 Android emulators simultaneously after the changes:
Success!!! May the sharding begin!
Related Links:
- Stack Overflow: http://stackoverflow.com/questions/21031903/how-to-fix-hax-is-not-working-and-emulator-runs-in-emulation-mode
- LinkedIn Engineering Blog “3×3: Speeding Up Mobile Releases” by Drew Hannay – https://engineering.linkedin.com/blog/2016/02/3×3–speeding-up-mobile-releases