Home » Android » How to create Android Virtual Device with command line and avdmanager?

How to create Android Virtual Device with command line and avdmanager?

Posted by: admin April 23, 2020 Leave a comment

Questions:

I can not create a device with avdmanager command line:

$ Android/Sdk/tools/bin/avdmanager create avd --name Nexus6P --tag 11 --package 'system-images;android-23;google_apis;x86_64'
Error: Invalid --tag 11 for the selected package.

$ Android/Sdk/tools/bin/avdmanager create avd --name Nexus6P --package 'system-images;android-23;google_apis;x86_64'
Error: Invalid --tag default for the selected package.

$ Android/Sdk/tools/bin/avdmanager list
Available Android Virtual Devices:
Available devices definitions:
...
---------
id: 11 or "Nexus 6P"
    Name: Nexus 6P
    OEM : Google
---------

Any idea?

How to&Answers:

If you don’t care about it being a Nexus 6P, you can run

echo no | Android/Sdk/tools/bin/avdmanager create avd --force --name testAVD --abi google_apis/x86_64 --package 'system-images;android-23;google_apis;x86_64'

Answer:

The solution from @Gregriggins36 works. Here the detailed solution I use on Linux (Fedora 27)

List the device definitions available:

~/Android/Sdk/tools/bin/avdmanager list
...
---------
id: 11 or "Nexus 6P"
    Name: Nexus 6P
    OEM : Google
---------
...

create a virtual device based on device definition "Nexus 6P"

~/Android/Sdk/tools/bin/avdmanager create avd --force --name Nexus6P --abi google_apis/x86_64 --package 'system-images;android-23;google_apis;x86_64' --device "Nexus 6P"

list virtual devices available

~/Android/Sdk/tools/bin/avdmanager list avd
Name: Nexus6P
Device: Nexus 6P (Google)
Path: /home/guillaume/.android/avd/Nexus6P.avd
Target: Google APIs (Google Inc.)
        Based on: Android 6.0 (Marshmallow) Tag/ABI: google_apis/x86_64

start the emulation of our new virtual device

~/Android/Sdk/tools/emulator -avd Nexus6P -skin 1440x2560

Answer:

Here is my command that works on Mac.
Notice:

  1. x86 and x86_64 are different ABIs.
  2. You need to download the system_image from sdkmanager first

$  avdmanager create avd --force --name testAVD --abi google_apis/x86 --package 'system-images;android-23;google_apis;x86'

Do you wish to create a custom hardware profile? [no] no

$  avdmanager list avd


Name: testAVD
Path: /Users/xj/.android/avd/testAVD.avd
Target: Google APIs (Google Inc.)
      Based on: Android 6.0 (Marshmallow) Tag/ABI: google_apis/x86