cur4so
cur4so

Reputation: 1810

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?

Upvotes: 9

Views: 22340

Answers (4)

NickUnuchek
NickUnuchek

Reputation: 12847

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

Upvotes: 8

Kevin Kanyi
Kevin Kanyi

Reputation: 51

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.

Upvotes: 5

Sergii Pechenizkyi
Sergii Pechenizkyi

Reputation: 22232

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.

Upvotes: 10

Jamal Eason
Jamal Eason

Reputation: 6588

You can download the Android Emulator using the new sdkmanager command line tool and create AVDs via the new avdmanager command line tool. It is easier to do these tasks with the Android Studio AVD manager.

Upvotes: 1

Related Questions