ManagedVirtualDevice

@Incubating
public interface ManagedVirtualDevice extends Device


Device type for emulators to be managed by the Android Gradle Plugin.

When a device group containing this device is run for tests, Gradle will:

  1. Automatically start up an emulator matching the device definition. Including downloading any and all required system image files and creating the avd.

  2. Run the tests on this device.

  3. Close the emulator upon completion.

These APIs are experimental and may change without notice.

Summary

Public methods

abstract int

The api level of Android to be run on the device.

abstract String

The api version code of Android to be run on the device.

abstract @NonNull String

The hardware profile of the device to be emulated.

abstract boolean

Whether the image must be a 64 bit image.

abstract @NonNull String

Which source the system image should come from.

abstract void
setApiLevel(int apiLevel)

The api level of Android to be run on the device.

abstract void

The api version code of Android to be run on the device.

abstract void

The hardware profile of the device to be emulated.

abstract void
setRequire64Bit(boolean require64Bit)

Whether the image must be a 64 bit image.

abstract void
setSystemImageSource(@NonNull String systemImageSource)

Which source the system image should come from.

Public methods

getApiLevel

abstract int getApiLevel()

The api level of Android to be run on the device. Setting this it will override previous calls of apiLevel or apiPreview setters. Only one of apiLevel and apiPreview should be set.

See uses-sdk element documentation for a list of valid values.

getApiPreview

@Incubating
abstract String getApiPreview()

The api version code of Android to be run on the device. Setting this it will override previous calls of apiLevel or apiPreview setters. Only one of apiLevel and apiPreview should be set.

See uses-sdk element documentation for a list of valid values.

getDevice

abstract @NonNull String getDevice()

The hardware profile of the device to be emulated.

getRequire64Bit

abstract boolean getRequire64Bit()

Whether the image must be a 64 bit image. Defaults to false.

On x86_64 machines: When false, the managed device will use the 32 bit image if available with the given api level and source, otherwise the 64 bit image will be used. When true, the 64 image must be used and setup will fail if an appropriate image does not exist. On arm machines: The value of this parameter has no effect. An arm64 image is always selected.

getSystemImageSource

abstract @NonNull String getSystemImageSource()

Which source the system image should come from. Either "google", "google-atd", "aosp", or "aosp-atd". You can also specify an explicit source such as "google_apis_playstore".

"google", the default, will select Google APIs images for the device. "google-atd" will use automated test device images from Google APIs. "aosp" will use the Android Open Source Project images for the device. "aosp-atd" will use automated test device image from the Android Open Source Project.

setApiLevel

abstract void setApiLevel(int apiLevel)

The api level of Android to be run on the device. Setting this it will override previous calls of apiLevel or apiPreview setters. Only one of apiLevel and apiPreview should be set.

See uses-sdk element documentation for a list of valid values.

setApiPreview

@Incubating
abstract void setApiPreview(String apiPreview)

The api version code of Android to be run on the device. Setting this it will override previous calls of apiLevel or apiPreview setters. Only one of apiLevel and apiPreview should be set.

See uses-sdk element documentation for a list of valid values.

setDevice

abstract void setDevice(@NonNull String device)

The hardware profile of the device to be emulated.

setRequire64Bit

abstract void setRequire64Bit(boolean require64Bit)

Whether the image must be a 64 bit image. Defaults to false.

On x86_64 machines: When false, the managed device will use the 32 bit image if available with the given api level and source, otherwise the 64 bit image will be used. When true, the 64 image must be used and setup will fail if an appropriate image does not exist. On arm machines: The value of this parameter has no effect. An arm64 image is always selected.

setSystemImageSource

abstract void setSystemImageSource(@NonNull String systemImageSource)

Which source the system image should come from. Either "google", "google-atd", "aosp", or "aosp-atd". You can also specify an explicit source such as "google_apis_playstore".

"google", the default, will select Google APIs images for the device. "google-atd" will use automated test device images from Google APIs. "aosp" will use the Android Open Source Project images for the device. "aosp-atd" will use automated test device image from the Android Open Source Project.