Skip to content

BCV tasks not registered for Android libraries when using AGP 9.x (built-in Kotlin) #312

@LikeTheSalad

Description

@LikeTheSalad

Description

Starting with AGP 9.0, the Android Gradle Plugin provides built-in Kotlin compilation support and no longer requires (and actively blocks) the org.jetbrains.kotlin.android plugin. This means BCV's Android task registration never fires, since it hooks into the kotlin-android plugin ID:

https://github.com/Kotlin/binary-compatibility-validator/blob/0.18.1/src/main/kotlin/BinaryCompatibilityValidatorPlugin.kt#L131

private fun configureAndroidPluginForKotlinLibrary(
    project: Project,
    extension: ApiValidationExtension,
    jvmRuntimeClasspath: NamedDomainObjectProvider<Configuration>
) = configurePlugin("kotlin-android", project, extension) {
    // ...
}

As a result, apiDump and apiCheck tasks are never created for any Android library module when using AGP 9.x. The check task also does not include any BCV validation.

The migration path is also blocked

The BCV README recommends migrating to the built-in ABI validation in the Kotlin Gradle plugin (kotlin { abiValidation { ... } }). However, this is also not possible with AGP 9.x because:

  1. KGP's abiValidation DSL is only available on the KotlinAndroidProjectExtension registered by the kotlin-android plugin.
  2. AGP 9.x blocks applying kotlin-android with the error:

    The 'org.jetbrains.kotlin.android' plugin is no longer required for Kotlin support since AGP 9.0.

  3. The kotlin {} extension registered by AGP 9.x does not include the abiValidation DSL.

This creates a gap where neither the standalone BCV plugin nor the KGP built-in replacement can provide API validation for Android library projects using AGP 9.x.

Environment

  • AGP: 9.0.1
  • Kotlin: 2.2.21
  • BCV: 0.18.1
  • Gradle: 9.3.1

Steps to reproduce

  1. Create an Android library project using AGP 9.x (no kotlin-android plugin applied — AGP handles Kotlin natively).
  2. Apply org.jetbrains.kotlinx.binary-compatibility-validator version 0.18.1.
  3. Run ./gradlew apiDump or ./gradlew apiCheck.
  4. Observe: Task 'apiDump' not found.

Expected behavior

BCV should detect Android library modules using AGP 9.x's built-in Kotlin and register apiDump/apiCheck tasks for them, or the KGP built-in abiValidation should be usable alongside AGP 9.x.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions