Pixel 2 Emulator / Virtual Device not in AVD manager device list

Viewed 3471

Question

Can you only create the Pixel 2 virtual device via Android Studio (v3.1.4) and not via avdmanager?

What we want to do

Use avdmanager to create a Pixel 2 device automatically (Continuous Integration script based on avdmanger). We need to use the pixel 2 device explicitly.

Problem

Executing $ANDROID_HOME/tools/bin/avdmanager list does not return a Pixel 2 hardware profile but returns an error:

Parsing ****
Available Android Virtual Devices:
The following Android Virtual Devices could not be loaded:
    Name: Pixel_2_API_28
    Path: /home/user/.android/avd/Pixel_2_API_28.avd
   Error: Google pixel_2 no longer exists as a device
Available devices definitions:
id: 0 or "tv_1080p"
    Name: Android TV (1080p)
    OEM : Google
    Tag : android-tv

Additional Details

I had to execute the following command to execute the avdmanager command with JAVA 10.0.2 export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'. Else, I receive the error mentioned here: Failed to install android-sdk: "java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema"

3 Answers

I was able to find the description of the Pixel 2 that the Android Studio plugin uses in

com/android/sdklib/devices/nexus.xml,

that file is in

$ANDROID_HOME/plugins/android/lib/sdklib.jar

but I haven't been able to figure out how to get avdmanager to load the same sdklib that the Android Studio plugin uses.

I've solved the problem using AndroidSDK/cmdline-tools/latest/bin/avdmanager.

enter image description here

The old AndroidSDK/tools folder has been deprecated and should not be used anymore

either edit the AVD's config.ini - or change it's model in the AVD Manager.

what's left is:

id: 17 or "pixel"
    Name: Pixel
    OEM : Google
---------
id: 18 or "pixel_c"
    Name: Pixel C
    OEM : Google
---------
id: 19 or "pixel_xl"
    Name: Pixel XL
    OEM : Google

using Java 10 should not make much difference, while the device definition is not available anymore.

if you really insist on the Pixel 2; you could add the device definition into ~/.android/devices.xml.

Related