As pointed in How to create Android Virtual Device with command line and avdmanager?
one can in principle create AVD from command line. Though it is not straightforward. Following the docs, there should be an option -t
that specifies what particular device to emulate by specifying targetId
.
Unfortunately, as of version 25.3.1 avdmanager
does not recognize option -t
.
There is an option --tag
but it does not seem to be a -t
equivalent, since it does not recognise the provided targetId
(taken from the list).
How can I specify what device to emulate?
For e.g. echo "no" | avdmanager --verbose create avd --force --name x86 --device "4in WVGA (Nexus S)" --package "system-images;android-24;google_apis;x86" --tag "google_apis" --abi "x86"
Where:
Usage:
avdmanager [global options] create avd [action options]
Global options:
-s --silent : Silent mode, shows errors only.
-v --verbose : Verbose mode, shows errors, warnings and all messages.
--clear-cache: Clear the SDK Manager repository manifest cache.
-h --help : Help on a specific command.
Action "create avd":
Creates a new Android Virtual Device.
Options:
-a --snapshot: Place a snapshots file in the AVD, to enable persistence.
-c --sdcard : Path to a shared SD card image, or size of a new sdcard for
the new AVD.
-g --tag : The sys-img tag to use for the AVD. The default is to
auto-select if the platform has only one tag for its system
images.
-p --path : Directory where the new AVD will be created.
-k --package : Package path of the system image for this AVD (e.g.
'system-images;android-19;google_apis;x86'). [required]
-n --name : Name of the new AVD. [required]
-f --force : Forces creation (overwrites an existing AVD)
-b --abi : The ABI to use for the AVD. The default is to auto-select the
ABI if the platform has only one ABI for its system images.
-d --device : The optional device definition to use. Can be a device index
or id.
cd $ANDROID_HOME/tools/bin
yes | ./sdkmanager emulator
export PATH="${ANDROID_HOME}/emulator:${PATH}"
./sdkmanager "system-images;android-25;google_apis;x86"
yes | ./sdkmanager --licenses
./avdmanager list device
./avdmanager create avd -n test -k "system-images;android-25;google_apis;x86"
cd $ANDROID_HOME/tools
sudo apt-get install cpu-checker
kvm-ok
sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
./emulator -avd test
The avdmanager tool and sdkmanager are provided in the Android SDK Tools package (25.3.0 and higher) and is located in {your_android_sdk_directory}/tools/bin/ in terminal run following commands:
pixel is the name i gave to the avd.
"system-images;android-26;google_apis;x86_64" got from ./sdkmanager list in Installed packages
"17" is device id got from ./avdmanager list device
change directory to:
To open emulator run command:
Pixel is the name given previously to the avd.
Hope it helps others with the new version.
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