Why launching more than 2 AVDs works only under sp

2019-07-10 16:22发布

问题:

I came across weird problem that I dont fully understand. I try to start more than 2 AVD from terminal. It works even for 4 AVDs but only on special conditions.

There is a code I use for 3 AVDs:

echo "no" | $ANDROID_HOME/tools/android create avd --name "Test-Emulator-API23-Nexus-5" --target "Google Inc.:Google APIs:23" --abi google_apis/x86_64  --device "Nexus 5" --skin "1080x1920"
echo "no" | $ANDROID_HOME/tools/android create avd --name "Test-Emulator-API23-Nexus-7" --target "Google Inc.:Google APIs:23" --abi google_apis/x86_64  --device "Nexus 7" --skin "1200x1920"
echo "no" | $ANDROID_HOME/tools/android create avd --name "Test-Emulator-API23-Nexus-10" --target "Google Inc.:Google APIs:23" --abi google_apis/x86_64  --device "Nexus 10" --skin "2560x1600"

$ANDROID_HOME/platform-tools/adb kill-server
$ANDROID_HOME/platform-tools/adb start-server

$ANDROID_HOME/tools/emulator -port 5556 -avd Test-Emulator-API23-Nexus-5  -gpu on &>/dev/null &
$ANDROID_HOME/tools/emulator -port 5558 -avd Test-Emulator-API23-Nexus-7  -gpu on &>/dev/null &
$ANDROID_HOME/tools/emulator -port 5560 -avd Test-Emulator-API23-Nexus-10  -gpu on &>/dev/null &

It works when I copy paste last 3 lanes which launches AVD to terminal AT ONCE. Then all 3 AVDs start at the same time and successfully launch. It also works for 4 AVDs.

It won't allow me to launch more than 2 AVDs if I try to do it sequentially. So I put 1st launch lane for Nexus-5. I wait until it boots completely. Then I put 2nd launch lane for Nexus-7 - it also boots successfully. And then if I try to launch more AVD I get freeze - black screen freeze on startup.

Any idea why this happens? Why can I launch many AVDs at the same time, but I can't start them one by one?

回答1:

Problem is related to memory allowance set to HAXM. My HAXM RAM usage by default was 2gb. After reinstalling HAXM

https://software.intel.com/en-us/android/articles/intel-hardware-accelerated-execution-manager

and assigning 6gb of memory to it, I am able to start 4 AVDs in sequence.

My guess why it worked before was: because all AVDs were started at once - in the same moment, all of them passed memory limit check and because of that they were allowed to run.



标签: android avd