Skip to content

fix: the Android Gradle plugin's NDK beats ANDROID_NDK_HOME - #20

Merged
lemcoder merged 1 commit into
mainfrom
fix/agp-ndk-over-environment
Nov 5, 2026
Merged

lemcoder merged 1 commit into
mainfrom
fix/agp-ndk-over-environment

Conversation

@lemcoder

@lemcoder lemcoder commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Problem

androidNdk tried ANDROID_NDK_HOME before the module's Android Gradle plugin NDK. GitHub's runner images preset that variable to NDK 27, so MikroSoundFont, on NDK 28, published 4 KB-aligned libraries from CI with no message (#19).

Change

  • Order: DSL, Gradle property, AGP's NDK, ANDROID_NDK_HOME. An AGP NDK that isn't installed still falls through to the environment variable, and modules without AGP are unaffected.
  • Warning: when ANDROID_NDK_HOME names a different NDK and goes unused, tasks using the NDK warn once per build, naming both paths. It's a build service called as tasks run, so it appears on a configuration cache hit and stays quiet in modules that build nothing for Android.
  • konanConfig lists ANDROID_NDK_HOME=… is not used.
  • Docs: README, CLAUDE.md and the example READMEs.

Behaviour change: in a module with AGP, an ANDROID_NDK_HOME set on purpose no longer wins when AGP's NDK is installed. konan.config.androidNdk or the DSL still override AGP, and the warning says so.

Tests

  • the Android Gradle plugin's NDK beats ANDROID_NDK_HOME…: AGP beats the environment, the Gradle property beats AGP, and an AGP NDK that isn't installed leaves the environment. It fails without the fix.
  • an ANDROID_NDK_HOME the Android Gradle plugin's NDK overrides is warned about once: two Android targets, one warning; none when both name the same NDK.
  • AGP is now on the TestKit classpath (withPluginClasspathAndAgp). Both tests skip on the Gradle 8.7 run, where AGP 9 doesn't run.
  • Full suite: 67 passed, 2 skipped; on Gradle 8.7 with Kotlin 2.0: 64 passed, 5 skipped.
  • examples/android with ANDROID_NDK_HOME on NDK 29 and AGP on 28: built with 28, one warning per build, also on a configuration cache hit, and the Android tasks stayed UP-TO-DATE.

Fixes #19

🤖 Generated with Claude Code

androidNdk tried the environment before the module's AGP NDK, so an
ANDROID_NDK_HOME nobody chose won without a message. GitHub's runners preset
it to NDK 27, and MikroSoundFont, on NDK 28, published 4 KB-aligned libraries.

The order is now DSL, Gradle property, AGP's NDK, environment. An AGP NDK
that is not installed still leaves the environment variable.

An ANDROID_NDK_HOME that names another NDK and goes unused is reported:
konanConfig lists it, and tasks using the NDK warn once per build through a
build service, as they run, so the warning survives a configuration cache hit.

AGP is on the test classpath for the first time, for the fixtures that apply it.

Fixes #19

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lemcoder
lemcoder merged commit a0f2116 into main Nov 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ANDROID_NDK_HOME silently overrides the Android Gradle plugin's NDK

1 participant