KotlinMultiplatformAndroidVariant

Added in 8.2.0-beta03

@Incubating
interface KotlinMultiplatformAndroidVariant : HasDeviceTests, HasAndroidTest, HasUnitTest


Properties for the main Variant of a kotlin multiplatform android library

Summary

Public properties

Artifacts

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

FileCollection

Access to the variant's compile classpath.

Instrumentation

Access to the variant's instrumentation options.

LifecycleTasks

Provides access to the LifecycleTasks created for this component.

String

The name of the variant

List<Component>

List of the components nested in the main variant, the returned list may contain:

Inherited properties

From com.android.build.api.variant.HasAndroidTest
AndroidTest?

Variant's AndroidTest configuration, or null if android tests are disabled for this variant.

TestedComponentPackaging

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

From com.android.build.api.variant.HasDeviceTests
List<DeviceTest>

Variant's List of DeviceTest configurations, or empty if all devices tests (like android tests) are disabled for this variant.

From com.android.build.api.variant.HasUnitTest
UnitTest?

Variant's UnitTest, or null if the unit tests for this variant are disabled.

Public properties

artifacts

Added in 8.2.0-beta03
val artifactsArtifacts

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

compileClasspath

Added in 8.2.0-beta03
val compileClasspathFileCollection

Access to the variant's compile classpath.

The returned FileCollection should not be resolved until execution time.

instrumentation

Added in 8.2.0-beta03
val instrumentationInstrumentation

Access to the variant's instrumentation options.

lifecycleTasks

Added in 8.4.2
val lifecycleTasksLifecycleTasks

Provides access to the LifecycleTasks created for this component.

name

Added in 8.2.0-beta03
val nameString

The name of the variant

nestedComponents

Added in 8.4.2
val nestedComponentsList<Component>

List of the components nested in the main variant, the returned list may contain:

  • UnitTest component if the unit tests for this variant are enabled,

  • AndroidTest component if this variant HasDeviceTests and android tests for this variant are enabled,

Use this list to do operations on all nested components of this variant without having to manually check whether the variant has each component.

Example:

androidComponents {
onVariant { variant ->
variant.nestedComponents.forEach { component ->
component.instrumentation.transformClassesWith(
AsmClassVisitorFactoryImpl.class,
InstrumentationScope.Project) { params -> params.x = "value" }
instrumentation.setAsmFramesComputationMode(COMPUTE_FRAMES_FOR_INSTRUMENTED_METHODS)
}
}
}