Skip to content

Fix kt_android emitting an empty ABI .api dump (#112)#115

Draft
sugarmanz wants to merge 2 commits into
mainfrom
bugfix/112-kt-android-abi-target
Draft

Fix kt_android emitting an empty ABI .api dump (#112)#115
sugarmanz wants to merge 2 commits into
mainfrom
bugfix/112-kt-android-abi-target

Conversation

@sugarmanz

@sugarmanz sugarmanz commented Jun 29, 2026

Copy link
Copy Markdown
Member

Fixes #112

kt_android produced an empty .api ABI dump, while kt_jvm worked correctly.

Root cause

kt_android builds two targets: a :{name}-base kt_android_library that actually compiles the Kotlin (populated ABI jar), and the published :{name} android_library that only re-exports the base via exports and carries no sources of its own. The ABI dump (abi()) was pointed at :{name} — whose own output jar has no declarations — so the .api came out empty. kt_jvm is unaffected because there the named target is the compiling library.

Fix

kt_android_library_and_test now returns the base target's label it created, and kt_android passes that label to abi(target = ...). The abi() call stays in kt_android alongside lint/distribution (unchanged organization) — it just dumps the base library that actually holds the compiled public surface, using the exact label the owner produced instead of re-deriving the name. Generated target names ({name}-abi-dump / -abi-check / -abi-update) and the golden api/{name}.api path are unchanged, matching kt_jvm and the BCV layout.

Verification

  • New kt_android example under examples/kotlin with a checked-in golden .api; //:android_lib-abi-dump now emits the populated public surface and //:android_lib-abi-check passes.
  • Runs in //examples:all_integration_tests — the CI image (playerui/bazel-docker) provides Android SDK (android-35) + JDK 17; the example auto-detects the SDK via $ANDROID_HOME and pins no API level.

Follow-up (separate, in the player repo)

player must repoint its .api dump from //android/player:android to the new :{name}-abi target for the fix to take full effect downstream.

@sugarmanz sugarmanz force-pushed the bugfix/112-kt-android-abi-target branch from 07f6297 to d101695 Compare June 29, 2026 13:49
@sugarmanz sugarmanz added the patch Increment the patch version when merged label Jun 29, 2026
The published :{name} target is a source-less android_library that only
re-exports the kt_android_library base via exports, so its own output jar
carries no declarations and the ABI dump came out empty. Have
kt_android_library_and_test return the base label it creates, and dump that
instead of the wrapper; abi() stays in kt_android alongside lint/distribution.

Adds a kt_android example under examples/kotlin with a golden .api as
regression coverage (abi-check passes). The example moves to Bazel 9.1.1 to
match root (#111): the rules_android 0.7.2 -> rules_java 9.3.0 path needs
Bazel 9 for java_import's jars attr used by rules_kotlin's serialization ext.
@sugarmanz sugarmanz force-pushed the bugfix/112-kt-android-abi-target branch from d101695 to 5b0b5ea Compare June 29, 2026 14:06
@sugarmanz sugarmanz marked this pull request as ready for review June 29, 2026 14:09
@KetanReddy KetanReddy marked this pull request as draft July 7, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Increment the patch version when merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kotlin ABI emitting empty .api for kt_android

2 participants