Skip to content

No API tasks registered for Android target created by KMP plugin (AGP 9) #315

Description

@matt-ramotar

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. 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, 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 ("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 - WebRTC Client. JVM implementation. ktorio/ktor#5122
  2. Circuit - Phase 1 rework of Screen/PopResult serialization slackhq/circuit#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 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+.

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