Paul Ruiz
Paul Ruiz

Reputation: 2436

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!

Upvotes: 7

Views: 6305

Answers (4)

George Shalvashvili
George Shalvashvili

Reputation: 1560

-d seems to fix this

-d --device : The optional device definition to use. Can be a device index or id.

example:

.\avdmanager.bat create avd -n "API-24-Nougat-7.0" -k "system-images;android-27;google_apis_playstore;x86" -d 8

d 8 from .\avdmanager.bat list is Nexus 5, so the resolution becomes 1080x1920

Upvotes: 1

Chirag Anand
Chirag Anand

Reputation: 71

-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

Upvotes: 4

feuGene
feuGene

Reputation: 3991

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).

Upvotes: 2

albodelu
albodelu

Reputation: 7971

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.

Upvotes: 8

Related Questions