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 {