Open neupsh opened 2 months ago
Got one workaround: you can pass the target directory of workspace and it builds successfully:
CARGO_TARGET_DIR="../target" cargo android build
Perhaps there is a way to add one more else condition here to check for workspace and add workspace target directory if the CARGO_TARGET_DIR is not set. I wonder if there is a way to get the target directory from cargo itself.
Either use CARGO_TARGET_DIR
or set target-dir
in .cargo/config.toml
of your crate.
Describe the bug Cargo mobile does not support cargo workspaces. If I create a mobile project under a workspace, it fails to build as it cannot find built shared libraries under
<android project>/target/
. When you use workspace, those files are all under the<workspace-dir>/target
instead of under each member project inside the workspace.Steps To Reproduce
mkdir parent
) and add aCargo.toml
with the following contents:mkdir -p dioxus-mobile-test
and cd into it:cd dioxus-mobile-test
cargo mobile init
in there and use default values, selectwry
template and let it complete successfully.src/lib.rs
with the following:src/lib.rs
cargo android build
- It fails as it expects to link artifacts fromparent/dioxus-mobile-test/target/
instead of theparent/target/
directory which is where they are present when using cargo workspace feature.Expected behavior Android build is successful.
Platform and Versions (please complete the following information): Host OS: archlinux Target OS: android (aarch64-linux-android) Rustc: rustc 1.77.2 (25ef9e3d8 2024-04-09) Ouput of
cargo mobile doctor
:Other notes
If you rename the parent
Cargo.toml
toCargo.toml.backup
and try to build thedioxus-mobile-test
project again, it works without error, as it builds the artifacts inside thedioxus-mobile-test/target
directory and expects them there.Would be interested to know if there are any workarounds until this is resolved as well. Thank you.