fix: build Android against the devbox-managed JDK and NDK

This commit is contained in:
randogoth 2026-10-12 08:17:49 +03:00
parent 8426818712
commit ac998b394d
5 changed files with 35 additions and 2 deletions

View file

@ -1,5 +1,6 @@
gradle-wrapper.jar
/.gradle
/build
/captures/
/gradlew
/gradlew.bat

View file

@ -8,7 +8,10 @@ plugins {
android {
namespace = "page.mews.mews"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
// The devbox-managed SDK ships this NDK and is read-only, so Gradle
// cannot install the Flutter default beside it; the version is pinned to
// what nix-android-sdk provides.
ndkVersion = "27.0.12077973"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17

View file

@ -19,6 +19,25 @@ subprojects {
project.evaluationDependsOn(":app")
}
// The devbox-managed SDK ships one NDK and is read-only, so Gradle can never
// install another beside it. Plugin build scripts ask for Flutter's default
// NDK, which the SDK does not carry; every project is therefore pinned to
// the one it does. Matches the app's own pin in app/build.gradle.kts.
gradle.afterProject {
// The devbox-managed SDK ships one NDK and is read-only, so Gradle can
// never install another beside it. Plugin build scripts ask for
// Flutter's default NDK, which the SDK does not carry; every project
// is therefore pinned to the one it does, as the app itself is.
val android = extensions.findByName("android") ?: return@afterProject
try {
android::class.java
.getMethod("setNdkVersion", String::class.java)
.invoke(android, "27.0.12077973")
} catch (_: NoSuchMethodException) {
// Nothing to pin.
}
}
tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}