I'd like to use only the command-line tools to create a new virtual Android device. I want to create a virtual Pixel.
I'm able to create a new AVD but unfortunately I can't figure out how to correctly set the skin and the correct device screen resolution.
This is what I've tried thus far:
C:\Users\*******\AppData\Local\Android\Sdk\tools>bin\avdmanager create avd -n MyPixel2 -k "system-images;android-25;google_apis;x86" --device 17
When I run that AVD via the emulator
, I see a low-res device without any skin shown.
I am using Android SDK 25. And, unfortunately, it looks like https://developer.android.com/studio/command-line/avdmanager.html is out of date.
What you are describing is a limitation of the avdmanager
command right now. What the emulator tool needs is a device skin that will tell the emulator what dimensions the phone screen needs to be. The avdmanager
command is unable to take in a Device Skin Option at this time.
I recently created a helpful bash script that will create a device and then skin it using the device skins that are bundled with Android Studio.
Bash Repo
Take a look at the ReadME of the Repo for an in depth explanation of what the script does to make sure that the emulator will launch with the correct resolution.
But basically you are going to want to copy these lines into the config.ini of the device you created.
showDeviceFrame=yes
skin.dynamic=yes
skin.name={{skin_name}}
skin.path={{skin_path}}
hw.gpu.enabled=yes
hw.gpu.mode=auto
hw.ramSize=1536
And replace the {{skin_name}}
with the name of the skin in your ANDROID_HOME/skins
folder. As well as replace the {{skin_path}}
with the path to the skin in your ANDROID_HOME/skins
folder. The {{skin_path}}
is just the path to the folder that contains the layout
file.
If your SDK Directory doesn't have a skins folder than copy the skins folder located in my repository, to your SDK Directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With