Skip to content
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

cargo apk build gives No such file... without further info #48

Open
TomMD opened this issue Jan 2, 2024 · 3 comments
Open

cargo apk build gives No such file... without further info #48

TomMD opened this issue Jan 2, 2024 · 3 comments

Comments

@TomMD
Copy link

TomMD commented Jan 2, 2024

In a nut shell:

~/dev/rust-android-examples/na-mainloop]$ cargo apk build
Using package `na-mainloop` in `/home/tommd/dev/rust-android-examples/na-mainloop/Cargo.toml`
Error: No such file or directory (os error 2)

This is after a system setup which I tried to capture:

  1. Have rustup and java jdk:
$ nix-shell -p jdk -p rustup
  1. Download the 'commandline only' tools (https://developer.android.com/studio) and use sdkmanager to get the sdk
    unzip thing and cd in then
$ export ANDROID_HOME=$(pwd)
$ $ANDROID_HOME/bin/sdkmanager --sdk_root=$ANDROID_HOME --install "build-tools;34.0.0" "cmdline-tools;latest" "extras;android;m2repository" "ndk;26.1.10909125" "platforms;android-31"

(Notice the 'ANDROID_SDK_HOME' envvar is deprecated, contrary to the readme)

  1. Download the NDK (https://developer.android.com/ndk/downloads)
    unzip thing and cd
$ export ANDROID_NDK_HOME=$(pwd)
  1. Run a demo (https://github.com/rust-mobile/rust-android-examples/tree/main/na-mainloop)
$ rustup default 1.70.0
$ rustup target install aarch64-linux-android
$ git clone https://github.com/rust-mobile/rust-android-examples
$ cd rust-android-examples/na-mainloop
$ cargo install cargo-ndk
$ cargo ndk -t arm64-v8a -o app/src/main/jniLibs/  build
$ cargo install cargo-apk
$ cargo apk build
Using package `na-mainloop` in `..../dev/rust-android-examples/na-mainloop/Cargo.toml`
Error: No such file or directory (os error 2)
@MarijnS95 MarijnS95 transferred this issue from rust-mobile/ndk Jan 2, 2024
@MarijnS95
Copy link
Member

MarijnS95 commented Jan 2, 2024

Moving this to cargo-apk because the issue described is either a build system issue, or a rust-android-examples (via android-activity) example setup/documentation issue. Neither of which relate to the native libandroid.so (and friends) bindings provided by the ndk crate.

@rednaz1337
Copy link

strace tells me this:

openat(AT_FDCWD, "/home/hz/programmieren/rust/my-project/target/aarch64-linux-android/debug/build", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)

I have a global cargo target directory configured in ~/.cargo/config.toml. As a workaround I created a cargo config in my project directory, which sets build.target-dir = "target". This fixes the issue for me.

@MarijnS95
Copy link
Member

MarijnS95 commented Mar 16, 2024

@rednaz1337 that must originate from the following snippet:

let deps_dir = target_dir
.join(target_triple)
.join(target_profile)
.join("build");

While target-dir is parsed from .cargo/confg.toml, as you found it is currently only detected in the package workspace, but not up-merged from parent directories and ultimately the global home folder config based on this structure: https://doc.rust-lang.org/cargo/reference/config.html#hierarchical-structure

This TODO is ""tracked"" at https://github.com/rust-mobile/cargo-subcommand/blob/de0458c0cedfad69717fbbc09a2ef23226318e10/src/subcommand.rs#L83-L88.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants