From 38e9bbc1d865477fcbaf8d5770d8a0cdc3e77831 Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Tue, 20 Oct 2026 13:00:29 +0600 Subject: [PATCH] fix(android): create intermediate directories for Rust targets to prevent runtime errors --- composeApp/build.gradle.kts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index edb6c6f7..ef0ab92f 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -18,6 +18,7 @@ import gobley.gradle.GobleyHost import gobley.gradle.Variant 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.TargetFormat import org.jetbrains.compose.reload.gradle.ComposeHotRun @@ -614,6 +615,15 @@ cargo { } } +// Gobley adds build/intermediates/rust// 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 // link (clang: "Exec format error"). Desktop packaging doesn't need them; Android is built on x86_64 runners. run {