Android Emulator from Command Line Has Weird Resol

2019-06-28 07:29发布

问题:

I'm creating an Android emulator for Espresso testing from a terminal via this command:

./avdmanager create avd -n TestEmulator1 -k "system-images;android-25;google_apis;x86_64" -c 2000M --tag "google_apis" --device "Nexus 5X"

However when I run the emulator, the resolution is really off

When I check it in the AVD Manager from Android Studio, it looks like the settings are correct. Is there something missing from my command that's causing this issue? It causes all of my tests to fail when run. Thanks!

回答1:

Add the skin resolution you need like this:

./avdmanager create avd -n TestEmulator1 -k "system-images;android-25;google_apis;x86_64" -c 2000M --tag "google_apis" --device "Nexus 5X"

./emulator -avd TestEmulator1 -no-window -skin 768x1280 &

Or try if something like this (-s "768x1280") still works with the new avdmanager:

android create avd --force -n nexus4-emulator -t "Google Inc.:Google APIs:"$EMULATOR_VERSION --abi $ANDROID_ABI -s "768x1280" --device "Nexus 4" -c 128M

Further information about emulators with a decent size here.



回答2:

I experienced this problem, and passing the desired resolution to emulator via the -skin "1440x2560" command-line argument is what worked for me.

I personally was trying to start a "Pixel XL" virtual device. I had hoped that the Android SDK could "just know" what resolution that device should run at, but apparently not. So I googled what resolution that device is supposed to have, and passed it in via -skin, and now I'm satisfied (enough).