Kotlin / Kotlin/binary-compatibility-validator
No API tasks registered for Android target created by KMP plugin (AGP 9)
- Dominant language
- Kotlin
- Stars
- 964
- Forks
- 68
- Avg merge
- 22h 36m
- Merged PRs (30d)
- 1
Description
## Summary
In KMP projects using AGP 9's `com.android.kotlin.multiplatform.library` plugin, BCV registers no `androidApiDump/androidApiCheck` tasks. Existing `api/android/*.api` golden files stop being validated or updated, while apiCheck stays green. There is no warning, so the coverage loss is silent.
This is distinct from [#312](https://github.com/Kotlin/binary-compatibility-validator/issues/312). That issue covers android-only modules where AGP 9's built-in Kotlin prevents BCV from recognizing any Kotlin plugin. This issue is the KMP case, where BCV does see the android target but skips it.
## Environment
- BCV: 0.18.1
- Kotlin (KGP): 2.3.21
- AGP: 9.2.1, `com.android.kotlin.multiplatform.library`
- Gradle: 9.6.1
## Reproduction
1. KMP module applying `org.jetbrains.kotlin.multiplatform`, `com.android.kotlin.multiplatform.library`, and `org.jetbrains.kotlinx.binary-compatibility-validator`, with `jvm()` and an `android {}` target.
2. Run `./gradlew :module:tasks --all | grep -i api`.
What you will observe: only `jvmApiDump/jvmApiCheck` (plus klib tasks). Before migrating (same module with KGP androidTarget() on AGP 8), `androidApiDump/androidApiCheck` existed and `api/android/module.api` was maintained.
Real-world reproducer: [MobileNativeFoundation/Store#736](https://github.com/MobileNativeFoundation/Store/pull/736), where the jvm dumps updated on a Kotlin bump but the android dumps could not, and CI stayed green.
## Root cause
`BinaryCompatibilityValidatorPlugin` matches `androidJvm` targets and then registers tasks via:
```
target.compilations.matching { it.name == "release" }
```
The AGP KMP plugin creates its target through KGP's external-target API (`KotlinMultiplatformAndroidLibraryTarget`, platform type `androidJvm`) with compilations named main, hostTest, and deviceTest. No compilation named release exists, so the matcher is empty and no task is registered.
JetBrains fixed the equivalent bug in KGP's built-in ABI validation in [KT-85950](https://youtrack.jetbrains.com/issue/KT-85950) ("only release compilations are read. However, we need to use main for this plugin"). It will ship in Kotlin 2.4.20-Beta2 (Sep 2026).
## Impact
The failure is silent. I did a quick search and found other examples where Android dumps have been frozen but JVM and klib dumps keep updating:
1. Ktor - https://github.com/ktorio/ktor/pull/5122
2. Circuit - https://github.com/slackhq/circuit/pull/2784
There are surely more libraries hitting this. Every KMP library will eventually cross this migration, since the legacy variant APIs the old path depends on are slated for removal in AGP 10.
## Ask
Understanding the plugin is in maintenance mode, in order of preference:
1. Also match the main compilation for `androidJvm` targets (the mirror of the [KT-85950](https://youtrack.jetbrains.com/issue/KT-85950) fix). Arguably within the stated maintenance scope of supporting current toolchain versions.
2. If a fix is out of scope, emit a warning when an `androidJvm` target is present but no compilation matched, and add a README note pointing AGP 9 KMP users to KGP's built-in abiValidation on Kotlin 2.4.20+.
Contributor guide
Research direction
Start at BinaryCompatibilityValidatorPlugin's androidJvm target handling and inspect the target.compilations matcher described in the issue. Reproduce the behavior with :module:tasks --all | grep -i api, then verify the chosen outcome: androidApiDump/androidApiCheck tasks register and validate api/android/module.api, or the plugin clearly warns when no compilation matches.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100