# Aapt2

[View Source](https://cs.android.com/search?q=file:com/android/build/api/variant/Aapt2.kt+class:com.android.build.api.variant.Aapt2) Added in 8.10.1


```
interface Aapt2
```

<br />

*** ** * ** ***

Provides structured access to AAPT2 tool.

An instance of `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/Aapt2` can be obtained via `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/AndroidComponents#sdkComponents()`

For example, this is the structure of a `https://docs.gradle.org/current/javadoc/org/gradle/api/Task.html` that runs aapt2:

```
abstract class MyTaskUsingAapt2: DefaultTask() {
  @get:Nested
  abstract val aapt2Input: Property<com.android.build.api.variant.Aapt2>

  @get:Inject
  abstract val execOperations: ExecOperations

  @TaskAction
  fun execute() {
    val aapt2Executable = aapt2Input.get().executable.get().asFile

    // execute aapt2 help
    execOperations.exec { spec ->
      spec.commandLine(aapt2Executable)
      spec.args("-h")
      spec.isIgnoreExitValue = true // -h returns exit value 1
    }
  }
}

tasks.register<MyTaskUsingAapt2>("myTaskUsingAapt2") {
  // get an instance of Aapt2
  this.aapt2Input.set(androidComponents.sdkComponents.aapt2)
}
```

## Summary

| ### Public properties |
|---|---|
| `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Provider.html<https://docs.gradle.org/current/javadoc/org/gradle/api/file/RegularFile.html>` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/Aapt2#executable()` Path to the [AAPT2](https://developer.android.com/tools/aapt2) executable file from the Android SDK |
| `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Provider.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/Aapt2#version()` Version of build tools. |

## Public properties

### executable

Added in 8.10.1

```
val executable: Provider<RegularFile>
```

Path to the [AAPT2](https://developer.android.com/tools/aapt2) executable file from the Android SDK

### version

Added in 8.10.1

```
val version: Provider<String>
```

Version of build tools. It is used as an input to allow correct build cache behaviour across different platforms