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

3

6

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"

Cabob answered 14/9, 2018 at 9:48 Comment(0)
S
3

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.

Staffan answered 10/12, 2018 at 21:10 Comment(1)
FWIW: I worked around the issue by creating the AVDs I wanted locally, and then cloning them to my CI build boxes. Maybe not ideal in your use case, but it worked for me.Staffan
P
2

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

Pump answered 15/1, 2021 at 11:57 Comment(0)
F
1

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.

Fluellen answered 14/9, 2018 at 9:59 Comment(3)
Maybe I was unclear: I need to use the pixel 2 because we need to test on this device. Also, this device needs to be created via avdmanager because on the CI environment there is no UI available to create the virtual device via Android Studio and just link it correctly afterwards.Cabob
@Cabob I hardly can imagine, that some virtual device name would make the least difference for an AVD (because it is all the same)... therefore, the pixel should be the equivalent (in case the screen-size matches). why you think they have removed it? you won't even have any device frame when running headless, therefore this is a complete misconception. while one still can create custom devices, if the screen size/dpi should vary - or simply attach a hardware device.Fluellen
Sorry for the late reply: We have an integration test which uses location updates. This test only runs on virtual devices of type pixel2 as on a normal device. My guess was that Google enhanced the emulated location service on this emulator in comparision to other emulated device profiles. Are you sure the implementation is not different between different profiles? Can you provide a source? In this case I could not explain why the test only works on pixel-2 emulators and not e.g. on pixel emulators with the same Android API.Cabob

© 2022 - 2024 — McMap. All rights reserved.