Kotlin / Kotlin/binary-compatibility-validator

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

Open
#312 2 comments 21 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
965
Forks
68
Avg merge
22h 36m
Merged PRs (30d)
1

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with configureAndroidPluginForKotlinLibrary in src/main/kotlin/BinaryCompatibilityValidatorPlugin.kt around line 131, then reproduce the issue with AGP 9.0.1, Kotlin 2.2.21, BCV 0.18.1, and Gradle 9.3.1. Done means Android library projects using AGP 9.x expose apiDump and apiCheck tasks and include BCV validation in check.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
build-system, mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.