# Component

# Component

```
interface Component : ComponentIdentity
```

|--------------------------------------------------------------------------------------------------------------------------------------------------|
| [com.android.build.api.variant.Component](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/Component#) |

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Direct Subclasses [Component](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/Component.html#),[TestComponent](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/TestComponent),[TestFixtures](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/TestFixtures) |---------------------------------------------------------------------------------------------------------------------------|--------| | [Component](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/Component.html#) | <br /> | | [TestComponent](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/TestComponent) | <br /> | | [TestFixtures](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/TestFixtures)   | <br /> | |

|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Indirect Subclasses [AndroidTest](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/AndroidTest),[AndroidTest](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/AndroidTest.html#),[AndroidTest](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/AndroidTest.html#),[AndroidTest](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/AndroidTest.html#),[ApplicationVariant](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/ApplicationVariant),[DynamicFeatureVariant](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/DynamicFeatureVariant),[LibraryVariant](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/LibraryVariant),[TestComponent](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/TestComponent.html#),[TestComponent](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/TestComponent.html#),[TestFixtures](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/TestFixtures.html#),[TestFixtures](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/TestFixtures.html#),[TestVariant](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/TestVariant), and 5 others. |-------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------| | [AndroidTest](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/AndroidTest)                     | Properties for the android test Variant of a module.                                                                                | | [AndroidTest](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/AndroidTest.html#)             | <br />                                                                                                                              | | [AndroidTest](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/AndroidTest.html#)             | <br />                                                                                                                              | | [AndroidTest](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/AndroidTest.html#)             | <br />                                                                                                                              | | [ApplicationVariant](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/ApplicationVariant)       | Properties for the main Variant of an application.                                                                                  | | [DynamicFeatureVariant](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/DynamicFeatureVariant) | <br />                                                                                                                              | | [LibraryVariant](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/LibraryVariant)               | [Variant](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/Variant)for Library projects   | | [TestComponent](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/TestComponent.html#)         | <br />                                                                                                                              | | [TestComponent](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/TestComponent.html#)         | <br />                                                                                                                              | | [TestFixtures](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/TestFixtures.html#)           | <br />                                                                                                                              | | [TestFixtures](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/TestFixtures.html#)           | <br />                                                                                                                              | | [TestVariant](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/TestVariant)                     | [Variant](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/Variant)for test-only modules. | | [UnitTest](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/UnitTest)                           | <br />                                                                                                                              | | [UnitTest](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/UnitTest.html#)                   | Properties for the unit test variant of a module.                                                                                   | | [UnitTest](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/UnitTest.html#)                   | Properties for the unit test variant of a module.                                                                                   | | [UnitTest](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/component/UnitTest.html#)                   | Properties for the unit test variant of a module.                                                                                   | | [Variant](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/Variant)                             | Parent interface for all types of variants.                                                                                         | |

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ||
|--------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [setAsmFramesComputationMode](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/Component#setAsmFramesComputationMode(com.android.build.api.instrumentation.FramesComputationMode))`(`mode:` `[FramesComputationMode](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/instrumentation/FramesComputationMode.html#)`)` Sets the frame computation mode that will be applied to the bytecode of the classes instrumented by ASM visitors registered through[transformClassesWith](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/Component#transformClassesWith(java.lang.Class,%20com.android.build.api.instrumentation.InstrumentationScope,%20kotlin.Function1)).                                                                                                                                      |
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [transformClassesWith](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/Component#transformClassesWith(java.lang.Class,%20com.android.build.api.instrumentation.InstrumentationScope,%20kotlin.Function1))`(`classVisitorFactoryImplClass:` `[Class](http://docs.oracle.com/javase/8/docs/api/java/lang/Class.html)<out` `[AsmClassVisitorFactory](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/instrumentation/AsmClassVisitorFactory.html#)<ParamT>>`, `scope:` `[InstrumentationScope](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/instrumentation/InstrumentationScope.html#)`, `instrumentationParamsConfig:` `(ParamT)` `->` `[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)`)` Registers an asm class visitor to instrument the classes defined by the given scope. |

|                                                                                                                                                                               ### Properties                                                                                                                                                                                ||
|----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| abstract[Artifacts](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/artifact/Artifacts.html#) | [artifacts](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/Component#artifacts:com.android.build.api.artifact.Artifacts) Access to the variant's buildable artifacts for build customization. |

| ### Inherited properties ||
|---|---|
| From class[ComponentIdentity](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/ComponentIdentity) |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?                                                                                                                                                                                                                                                            | [buildType](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/ComponentIdentity#buildType:kotlin.String) <br /> Build type name, might be replaced with access to locked DSL object once ready. <br />                                                                                                                                                                                                                                    | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?                                                                                                                                                                                                                                                            | [flavorName](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/ComponentIdentity#flavorName:kotlin.String) <br /> The multi-flavor name of the variant. This does not include the build type. If no flavors are present, this will return null The full name of the variant is queried via[name](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/ComponentIdentity#name:kotlin.String). <br /> | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)                                                                                                                                                                                                                                                             | [name](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/ComponentIdentity#name:kotlin.String) <br /> Component's name. <br />                                                                                                                                                                                                                                                                                                            | | [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)<[Pair](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-pair/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html),` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)>> | [productFlavors](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/ComponentIdentity#productFlavors:kotlin.collections.List) <br /> List of flavor names, might be replaced with access to locked DSL objects once ready. The order is properly sorted based on the associated dimension order. <br />                                                                                                                                    | ||

## Public methods

### setAsmFramesComputationMode

```
abstract fun setAsmFramesComputationMode(mode: FramesComputationMode): Unit
```

Sets the frame computation mode that will be applied to the bytecode of the classes instrumented by ASM visitors registered through[transformClassesWith](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/variant/Component#transformClassesWith(java.lang.Class,%20com.android.build.api.instrumentation.InstrumentationScope,%20kotlin.Function1)). The default mode is to[copy frames](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/instrumentation/FramesComputationMode.html#ENUM_VALUE:COPY_FRAMES).

When setting this multiple times, the mode with the highest enum value will be selected.  

### transformClassesWith

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

Registers an asm class visitor to instrument the classes defined by the given scope. An instance of the factory will be instantiated and used to create visitors for each class.

Example:  

```scdoc
androidComponentsExtension.onVariants(selector().all(), {
    transformClassesWith(AsmClassVisitorFactoryImpl.class,
                         InstrumentationScope.Project) { params ->
        params.x = "value"
    }
    setAsmFramesComputationMode(COMPUTE_FRAMES_FOR_INSTRUMENTED_METHODS)
})
```

This API is experimental and subject to breaking change and we strongly suggest you don't publish plugins that depend on it yet.

|                                                                                                                                                                                                                                                                                                                                                                                                       Parameters                                                                                                                                                                                                                                                                                                                                                                                                       ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| classVisitorFactoryImplClass:[Class](http://docs.oracle.com/javase/8/docs/api/java/lang/Class.html)\<out[AsmClassVisitorFactory](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/instrumentation/AsmClassVisitorFactory.html#)\<ParamT\>\> | the factory class implementing[AsmClassVisitorFactory](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/instrumentation/AsmClassVisitorFactory.html#)                                                                                                                                                                                                                                                                                                                                                 |
| scope:[InstrumentationScope](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/instrumentation/InstrumentationScope.html#)                                                                                                                   | either instrumenting the classes of the current project or the project and its dependencies                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| instrumentationParamsConfig:(ParamT)-\>[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                                                                                                                           | the configuration function to be applied to the instantiated[InstrumentationParameters](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/instrumentation/InstrumentationParameters.html#)object before passed to[AsmClassVisitorFactory.createClassVisitor](https://developer.android.com/reference/tools/gradle-api/7.0/com/android/build/api/instrumentation/AsmClassVisitorFactory.html#createClassVisitor(com.android.build.api.instrumentation.ClassContext,%20org.objectweb.asm.ClassVisitor)). |

## Properties

### artifacts

```
abstract val artifacts: Artifacts
```

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