Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install a specific emulator from command line with avdmanager?

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?

like image 804
cur4so Avatar asked Mar 23 '17 03:03

cur4so


3 Answers

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.
like image 176
Sergii Pechenizkyi Avatar answered Sep 29 '22 12:09

Sergii Pechenizkyi


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
like image 28
NickUnuchek Avatar answered Sep 29 '22 12:09

NickUnuchek


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:

  1. ./sdkmanager list
  2. ./avdmanager list device
  3. ./avdmanager create avd -n pixel -k "system-images;android-26;google_apis;x86_64" -d "17"

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:

  • cd {your_android_sdk_directory}/emulator

To open emulator run command:

  • ./emulator -avd pixel

Pixel is the name given previously to the avd.

Hope it helps others with the new version.

like image 35
Kevin Kanyi Avatar answered Sep 29 '22 11:09

Kevin Kanyi