fix(android): create intermediate directories for Rust targets to prevent runtime errors

This commit is contained in:
Kingkor Roy Tirtho 2026-10-20 13:00:29 +06:00
parent 64fb23e62b
commit 38e9bbc1d8

View File

@ -18,6 +18,7 @@
import gobley.gradle.GobleyHost import gobley.gradle.GobleyHost
import gobley.gradle.Variant import gobley.gradle.Variant
import gobley.gradle.cargo.dsl.jvm import gobley.gradle.cargo.dsl.jvm
import gobley.gradle.rust.targets.RustAndroidTarget
import dev.nucleusframework.desktop.application.dsl.NativeImageOptimization import dev.nucleusframework.desktop.application.dsl.NativeImageOptimization
import dev.nucleusframework.desktop.application.dsl.TargetFormat import dev.nucleusframework.desktop.application.dsl.TargetFormat
import org.jetbrains.compose.reload.gradle.ComposeHotRun import org.jetbrains.compose.reload.gradle.ComposeHotRun
@ -614,6 +615,15 @@ cargo {
} }
} }
// Gobley adds build/intermediates/rust/<triple>/<variant> as a jniLibs source dir, but AGP leaves source dirs
// that don't exist at configuration time out of the merge inputs. On a clean build (CI) libcompose_app.so would
// then silently miss the APK and crash at runtime with UnsatisfiedLinkError, so create the dirs up front.
RustAndroidTarget.entries.forEach { target ->
Variant.entries.forEach { variant ->
layout.buildDirectory.dir("intermediates/rust/${target.rustTriple}/$variant").get().asFile.mkdirs()
}
}
// Google only ships x86_64 Linux NDK toolchains, so on a Linux arm64 host the Android Rust targets can never // Google only ships x86_64 Linux NDK toolchains, so on a Linux arm64 host the Android Rust targets can never
// link (clang: "Exec format error"). Desktop packaging doesn't need them; Android is built on x86_64 runners. // link (clang: "Exec format error"). Desktop packaging doesn't need them; Android is built on x86_64 runners.
run { run {