Skip to content

Build silent failure when using "dx build" on android with oboe #3487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
LaurentMazare opened this issue Jan 2, 2025 · 3 comments
Open
Labels
bug Something isn't working cli Related to the dioxus-cli program
Milestone

Comments

@LaurentMazare
Copy link

Problem

When building a barebone dioxus project for android with the dx build command, the build process silently fails. If an apk file has already been built before that, no error is returned and the apk is unchanged. If no apk is present - e.g. after removing target, the bundling step here fails as the copy step does not have a source file.

Below is a repro for the issue together with the process output. This only happens when the oboe dependency is used.

Steps To Reproduce

I've put a repro in this repo dioxus-test.

$ sh build.sh
   ...
   0.747s  INFO Compiling [317/532]: dioxus_mobile
   0.747s  INFO Compiling [318/532]: dioxus
   1.36s  INFO Bundling app...
   1.36s ERROR err=Other(Failed to write main executable

Caused by:
    0: I/O Error: No such file or directory (os error 2)
    1: No such file or directory (os error 2))
   1.38s ERROR err=Other(Failed to write main executable

Caused by:
    0: I/O Error: No such file or directory (os error 2)
    1: No such file or directory (os error 2))

Expected behavior

I would expect the compiling step to fail and provide some compilation error if any.

Environment:

  • Dioxus version: dioxus 0.6.0, dx cli 0.6.1.
  • Rust version: rustc 1.82.0 (f6e511eec 2024-10-15)
  • OS info: linux 6.11.5-arch1-1
  • App platform: mobile - android

Questionnaire

@jkelleyrtp jkelleyrtp added this to the 0.6.2 milestone Jan 7, 2025
@jkelleyrtp jkelleyrtp added bug Something isn't working cli Related to the dioxus-cli program labels Jan 7, 2025
@rhaskia
Copy link
Contributor

rhaskia commented Jan 18, 2025

I found a fix here: fzyzcjy/flutter_rust_bridge#2209 (comment)
Turning on the feature shared-stdcxx for oboe, and copying $ANDROID_NDK/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/libc++_shared.so into \target\dx<crate>\debug\android\app\app\src\main\jniLibs makes oboe functional. Although I still am confused why there's no error when it fails to create the executable.

@ekarlsn
Copy link

ekarlsn commented Feb 20, 2025

I have the same problem, I managed to fix the compilation error as mentioned above, but Dioxus still does not include libc++_shared.so in the final apk-file, so the app fails to start.

java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found: needed by /data/app/~~oR8tD2nsII_TInqsB8tGng==/com.example.SoundOs-dIPSOOTdU8qrIguAPFX8dA==/base.apk!/lib/arm64-v8a/libdioxusmain.so in namespace clns-

And by inspecting the apk-file, we can indeed see that the library is not there (if it was, we would see it as an additional entry like lib/arm64-v8a/libc++_shared.so)

unzip -l target/dx/sound-os/debug/android/app/app/build/outputs/apk/debug/app-debug.apk | grep lib/
217672344  1981-01-01 01:01   lib/arm64-v8a/libdioxusmain.so

Any suggestion for a fix or a workaround would be greatly appreciated! 😄

@rhaskia
Copy link
Contributor

rhaskia commented May 16, 2025

cpal (which most major audio libraries use) now uses ndk::audio instead of oboe (#961), which I believe removes the C++ bindings and means this error should not show up unless you are using an older version of an audio library or using oboe directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli Related to the dioxus-cli program
Projects
None yet
Development

No branches or pull requests

4 participants