android10 / android10/Rust-Cross-Platform-Development

Cargo publish path does not point to folder with .so files

未关闭
#3 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Rust
星标
32
派生
5
PR 合并指标
30 天内没有已合并 PR

描述

## Issue
Following your blog post at: [Rust cross-platform... The Android part...](https://fernandocejas.com/blog/engineering/2023-07-27-rust-cross-platform-android/), I run into the issue that `cargo run --bin publish` gives the error `Error copying library file`. The full output that that command gives:
```rust
warning: `/home/{user}/github/Rust-Cross-Platform-Development/rust-library/cryptor_jni/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
Compiling cryptor_jni v0.1.0 (/home/{user}/github/Rust-Cross-Platform-Development/rust-library/cryptor_jni)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.33s
Running `target/debug/publish`
Message: Error copying library file
```

This error message comes from [line 150 in publish.rs](https://github.com/android10/Rust-Cross-Platform-Development/blob/8e9a6e636b1c292c7e855eccfc5b9070f1723fc9/rust-library/cryptor_jni/src/bin/publish.rs#L150).

## Probable cause
It seems that `cryptor_jni` is missing from the path used in `publish`.

The output paths:
- `cargo run --bin release` path: `Rust-Cross-Platform-Development/rust-library/cryptor_jni/target/armv7-linux-androideabi/release/libcryptor_jni.so`
- `cargo run --bin publish` path: `Rust-Cross-Platform-Development/rust-library/target/armv7-linux-androideabi/release/libcryptor_jni.so`

I executed the release and publish commands from: `Rust-Cross-Platform-Development/rust-library/cryptor_jni`

### Release from rust-library
If I run the command `rust-library$ cargo run --bin release` (instead of in `rust-library/cryptor_jni`), it throws the error:
```rust
error: multiple workspace roots found in the same workspace:
/home/{user}/github/Rust-Cross-Platform-Development/rust-library/cryptor_jni
/home/{user}/github/Rust-Cross-Platform-Development/rust-library
```

### Debugging
I modified that Err line to output `crate_lib_file_path` and `android_lib_file_path`:
```rust
return Err(format!("Error copying library file {} |\n{}", crate_lib_file_path, android_lib_file_path).into())
```

Which gives me:
```rust
Message: Error copying library file /home/{user}/github/Rust-Cross-Platform-Development/rust-library/target/armv7-linux-androideabi/release/libcryptor_jni.so |
/home/{user}/github/Rust-Cross-Platform-Development/android-sample/app/src/main/jniLibs/armeabi-v7a/libcryptor_jni.so
```

Comparing this to the output from `cargo run --bin release`:
```rust
warning: `/home/{user}/github/Rust-Cross-Platform-Development/rust-library/cryptor_jni/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s
Running `target/debug/release`
Message: Releasing Android Targets...Be patient... :)
Message: Building Android Target --> armv7-linux-androideabi
warning: `/home/{user}/github/Rust-Cross-Platform-Development/rust-library/cryptor_jni/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
Compiling cryptor_jni v0.1.0 (/home/{user}/github/Rust-Cross-Platform-Development/rust-library/cryptor_jni)
Finished `release` profile [optimized] target(s) in 0.49s
...
```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。