DeviceTest

Added in 8.4.0

@Incubating
interface DeviceTest : GeneratesTestApk, HasAndroidResources, TestComponent

Known direct subclasses
AndroidTest

Model for Android Test components that contains build-time properties


Model for Device Test components that contains build-time properties

This object is accessible on subtypes of Variant that implement HasDeviceTests, via HasDeviceTests.deviceTests. It is also part of Variant.nestedComponents.

The presence of this component in a variant is controlled by HasDeviceTestsBuilder.deviceTests and DeviceTestBuilder.enable which is accessible on subtypes of VariantBuilder that implement HasDeviceTestsBuilder

Summary

Public properties

Property<String>

Variant's application ID as present in the final manifest file of the APK.

MapProperty<StringBuildConfigField<Serializable>>

Variant's BuildConfigField which will be generated in the BuildConfig class.

Boolean

Whether test coverage is enabled for this device test.

ListProperty<RegularFile>

List of proguard configuration files for this variant.

SigningConfig?

Variant's signingConfig, initialized by the corresponding DSL element.

Inherited functions

From com.android.build.api.variant.Component
String
@Incubating
computeTaskName(action: String, subject: String)

Utility method to create unique task name for component.

Unit

This function is deprecated. Will be removed in v9.0, use the instrumentation block.

Unit
<ParamT : InstrumentationParameters> transformClassesWith(
    classVisitorFactoryImplClass: Class<AsmClassVisitorFactory<ParamT>>,
    scope: InstrumentationScope,
    instrumentationParamsConfig: (ParamT) -> Unit
)

This function is deprecated. Will be removed in v9.0, use the instrumentation block.

From com.android.build.api.variant.HasAndroidResources
ResValue.Key
makeResValueKey(type: String, name: String)

Make a ResValue.Key to interact with resValues's MapProperty

Inherited properties

From com.android.build.api.variant.Component
Configuration

Access to the variant's annotation processor Configuration; for example, the debugAnnotationProcessor Configuration for the debug variant.

Artifacts

Access to the variant's buildable artifacts for build customization.

FileCollection

Access to the variant's compile classpath.

Configuration

Access to the variant's compile Configuration; for example, the debugCompileClasspath Configuration for the debug variant.

Boolean

Whether the produced artifacts will be debuggable

Instrumentation

Access to the variant's instrumentation options.

JavaCompilation

Access to the variant's java compilation options.

LifecycleTasks

Provides access to the LifecycleTasks created for this component.

Provider<String>

The namespace of the generated R and BuildConfig classes.

Configuration

Access to the variant's runtime Configuration; for example, the debugRuntimeClasspath Configuration for the debug variant.

Sources

Access to variant's source files.

From com.android.build.api.variant.ComponentIdentity
String?

Build type name.

String?

The multi-flavor name of the variant.

String

Component's name.

List<Pair<StringString>>

List of flavor names.

From com.android.build.api.variant.GeneratesApk
AndroidResources

Variant's android resources processing configuration, initialized by the corresponding global DSL element.

Dexing

Variant's specific dexing options

AndroidVersion

Min SDK version for this variant

ApkPackaging

Variant's packagingOptions, initialized by the corresponding global DSL element.

Renderscript?

Variant specific settings for the renderscript compiler.

AndroidVersion

Target SDK version for this variant.

AndroidVersion

This property is deprecated. Replaced with targetSdk, will be removed in 9.0

From com.android.build.api.variant.GeneratesTestApk
Property<Boolean>

The functionalTest value to use to run the tests.

Property<Boolean>

The handleProfiling value to use to run the tests.

Property<String>

The instrumentationRunner to use to run the tests.

MapProperty<StringString>

The instrumentationRunnerArguments to use to run the tests.

Property<String>

The test label, or "" if none defined.

From com.android.build.api.variant.HasAndroidResources
Property<Boolean>

Variant's is pseudo locales enabled, initialized by the corresponding DSL elements.

MapProperty<ResValue.KeyResValue>

Variant's ResValue which will be generated.

From com.android.build.api.variant.TestComponent
MapProperty<StringString>

MapProperty of the test component's manifest placeholders.

Public properties

applicationId

Added in 8.9.0-alpha04
val applicationIdProperty<String>

Variant's application ID as present in the final manifest file of the APK.

buildConfigFields

Added in 8.4.0
val buildConfigFieldsMapProperty<StringBuildConfigField<Serializable>>

Variant's BuildConfigField which will be generated in the BuildConfig class.

codeCoverageEnabled

Added in 8.9.0-alpha04
val codeCoverageEnabledBoolean

Whether test coverage is enabled for this device test.

If enabled, this uses Jacoco to capture coverage and creates a report in the build directory.

You cannot change the value any longer, to change it, please use DeviceTestBuilder.enableCodeCoverage in the AndroidComponentsExtension.beforeVariants callback.

proguardFiles

Added in 8.4.0
val proguardFilesListProperty<RegularFile>

List of proguard configuration files for this variant. The list is initialized from the corresponding DSL element, and cannot be queried at configuration time. At configuration time, you can only add new elements to the list.

signingConfig

Added in 8.4.0
val signingConfigSigningConfig?

Variant's signingConfig, initialized by the corresponding DSL element.

Returns
SigningConfig?

Variant's config or null if the variant is not configured for signing.