Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Emulator from Command Line Has Weird Resolution

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

enter image description here

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!

like image 952
Paul Ruiz Avatar asked Apr 25 '17 15:04

Paul Ruiz


2 Answers

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.

like image 101
albodelu Avatar answered Sep 27 '22 16:09

albodelu


-skin option is deprecated now.

Try using hw.lcd.width, hw.lcd.height, and hw.lcd.depth to set resolution of the screen inside avd/<avd_name>/config.ini. Works for me.

Supported options are listed here: https://android.googlesource.com/platform/external/qemu/+/refs/heads/master/android/avd/hardware-properties.ini

like image 42
Chirag Anand Avatar answered Sep 27 '22 16:09

Chirag Anand