Closed LucasMW closed 1 year ago
This looks like a toolchain target not installed, which is weird because the android build command should do just that.
Can you post there result of rustup toolchain list
and rustup target list
?
I tried to upgrade my rust today, so the results now are not the same as they were yesterday:
rustup target list
aarch64-apple-darwin (installed)
aarch64-apple-ios (installed)
aarch64-apple-ios-sim
aarch64-linux-android (installed)
aarch64-pc-windows-msvc
aarch64-unknown-fuchsia
aarch64-unknown-linux-gnu
aarch64-unknown-linux-musl
aarch64-unknown-none
aarch64-unknown-none-softfloat
aarch64-unknown-uefi
arm-linux-androideabi
arm-unknown-linux-gnueabi
arm-unknown-linux-gnueabihf
arm-unknown-linux-musleabi
arm-unknown-linux-musleabihf
armebv7r-none-eabi
armebv7r-none-eabihf
armv5te-unknown-linux-gnueabi
armv5te-unknown-linux-musleabi
armv7-linux-androideabi (installed)
armv7-unknown-linux-gnueabi
armv7-unknown-linux-gnueabihf
armv7-unknown-linux-musleabi
armv7-unknown-linux-musleabihf
armv7a-none-eabi
armv7r-none-eabi
armv7r-none-eabihf
asmjs-unknown-emscripten
i586-pc-windows-msvc
i586-unknown-linux-gnu
i586-unknown-linux-musl
i686-linux-android
i686-pc-windows-gnu
i686-pc-windows-msvc
i686-unknown-freebsd
i686-unknown-linux-gnu
i686-unknown-linux-musl
i686-unknown-uefi
mips-unknown-linux-gnu
mips-unknown-linux-musl
mips64-unknown-linux-gnuabi64
mips64-unknown-linux-muslabi64
mips64el-unknown-linux-gnuabi64
mips64el-unknown-linux-muslabi64
mipsel-unknown-linux-gnu
mipsel-unknown-linux-musl
nvptx64-nvidia-cuda
powerpc-unknown-linux-gnu
powerpc64-unknown-linux-gnu
powerpc64le-unknown-linux-gnu
riscv32i-unknown-none-elf
riscv32imac-unknown-none-elf
riscv32imc-unknown-none-elf
riscv64gc-unknown-linux-gnu
riscv64gc-unknown-none-elf
riscv64imac-unknown-none-elf
s390x-unknown-linux-gnu
sparc64-unknown-linux-gnu
sparcv9-sun-solaris
thumbv6m-none-eabi
thumbv7em-none-eabi
thumbv7em-none-eabihf
thumbv7m-none-eabi
thumbv7neon-linux-androideabi
thumbv7neon-unknown-linux-gnueabihf
thumbv8m.base-none-eabi
thumbv8m.main-none-eabi
thumbv8m.main-none-eabihf
wasm32-unknown-emscripten
wasm32-unknown-unknown
wasm32-wasi
x86_64-apple-darwin (installed)
x86_64-apple-ios
x86_64-fortanix-unknown-sgx
x86_64-linux-android (installed)
x86_64-pc-solaris
x86_64-pc-windows-gnu
x86_64-pc-windows-msvc
x86_64-sun-solaris
x86_64-unknown-freebsd
x86_64-unknown-fuchsia
x86_64-unknown-illumos
x86_64-unknown-linux-gnu
x86_64-unknown-linux-gnux32
x86_64-unknown-linux-musl
x86_64-unknown-netbsd
x86_64-unknown-none
x86_64-unknown-redox
x86_64-unknown-uefi
rustup toolchain list
stable-x86_64-apple-darwin (default)
Couldn't make it work on iOS either. Serveral rust errors too.
However, I was able to make it run on fluttter run -d macos
Is it possible that you have installed rust through homebrew? If so please uninstall it. Homebrew rust installation is broken as it doesn't support any other toolchains through rust-up. I think super_native_extensions installs the toolchain through rustup but than invokes homebrew cargo because it's further up in PATH
. That should be easy to fix.
Yes, I have rust through homebrew. Ok I will try what you say and report the results
Re-installed rust. I was able to run on iOS now. Android however still has issues. Searching the internet, it appears to do with the NDK version (?)
Here's the log:
flutter build apk --release
💪 Building with sound null safety 💪
Finished dev [unoptimized + debuginfo] target(s) in 0.52s Running `/Users/lmenezes/flutter_projects/pixel_vision/build/super_native_extensions/build/rust_tool/debug/build_tool build_android`
Build tool failed: Command AR_armv7-linux-androideabi="/Users/lmenezes/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ar" CARGO_ENCODED_RUSTFLAGS="-L\u{1f}/Users/lmenezes/flutter_projects/pixel_vision/build/super_native_extensions/build/cargokit/libgcc_workaround/23" CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER="/Users/lmenezes/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi16-clang" CC_armv7-linux-androideabi="/Users/lmenezes/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi16-clang" CXX_armv7-linux-androideabi="/Users/lmenezes/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi16-clang++" "cargo" "build" "--manifest-path" "/Users/lmenezes/.pub-cache/hosted/pub.dev/super_native_extensions-0.4.0/android/../rust/Cargo.toml" "-p" "super_native_extensions" "--release" "--target" "armv7-linux-androideabi" "--target-dir" "/Users/lmenezes/flutter_projects/pixel_vision/build/super_native_extensions/build" failed with error exit status: 101; stderr: Downloading crates ... Downloaded android_logger v0.11.0 Downloaded same-file v1.0.6 Downloaded android_log-sys v0.2.0 Downloaded combine v4.6.3 Downloaded jni v0.19.0 Downloaded thiserror-impl v1.0.31 Downloaded bytes v1.1.0 Downloaded regex-syntax v0.6.25 Downloaded env_logger v0.9.0 Downloaded aho-corasick v0.7.18 Downloaded jni-sys v0.3.0 Downloaded walkdir v2.3.2 Downloaded thiserror v1.0.31 Downloaded regex v1.5.5 Downloaded irondash_jni_context v0.1.2 Downloaded cesu8 v1.1.0 Compiling super_native_extensions v0.1.0 (/Users/lmenezes/.pub-cache/hosted/pub.dev/super_native_extensions-0.4.0/rust) error: linker
/Users/lmenezes/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi16-clang
not found | = note: No such file or directory (os error 2)error: could not compile
super_native_extensions
(lib) due to previous errorstdout:
FAILURE: Build failed with an exception.
Where: Script '/Users/lmenezes/.pub-cache/hosted/pub.dev/super_native_extensions-0.4.0/cargokit/gradle/plugin.gradle' line: 57
What went wrong: Execution failed for task ':super_native_extensions:cargokitCargoBuildSuper_native_extensionsRelease'.
Process 'command '/Users/lmenezes/.pub-cache/hosted/pub.dev/super_native_extensions-0.4.0/cargokit/gradle/../run_rust_tool.sh'' finished with non-zero exit value 1
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 35s
Do you have ndk version 25.2.9519653 installed?
Yep
Nevermind. You need to set minSdkVersion
in your build.gradle
to something that the NDK supports. In this case that would be 19 (or newer).
How do I know which version of NDK and android should I use? Isn't this the most recent NDK? Which NDK version did/do you use for this?
By the way, tried with 19 and flutter said that this lib requires at least 23.
Generated an APK file, finally.
Every NDK has minimum version that it can target. But that's usually lower that what flutter requires anyway. The version of NDK depends on what you set in your application build.gradle
.
Closing this. The rustup
cargo should now be preferred and NDK installed automatically.
I get several rust errors when trying run flutter build apk
flutter build apk --release
``` 💪 Building with sound null safety 💪 Finished dev [unoptimized + debuginfo] target(s) in 0.07s Running `/Users/lmenezes/flutter_projects/pixel_vision/build/super_native_extensions/build/rust_tool/debug/build_tool build_android` Running Gradle task 'assembleRelease'... error[E0531]: cannot find tuple struct or tuple variant `Err` in this scope --> /Users/lmenezes/.cargo/registry/src/github.com-1ecc6299db9ec823/once_cell-1.16.0/src/imp_std.rs:201:24 | 201 | if let Err(new_queue) = exchange { | ^^^ not found in this scope error[E0531]: cannot find tuple struct or tuple variant `Err` in this scope --> /Users/lmenezes/.cargo/registry/src/github.com-1ecc6299db9ec823/once_cell-1.16.0/src/imp_std.rs:236:16 | 236 | if let Err(new_queue) = exchange { | ^^^ not found in this scope error[E0405]: cannot find trait `Sized` in this scope --> /Users/lmenezes/.cargo/registry/src/github.com-1ecc6299db9ec823/once_cell-1.16.0/src/imp_std.rs:260:12 | 260 | T: Sized, | ^^^^^ not found in this scope error[E0405]: cannot find trait `Sized` in this scope --> /Users/lmenezes/.cargo/registry/src/github.com-1ecc6299db9ec823/once_cell-1.16.0/src/imp_std.rs:272:12 | 272 | T: Sized, | ^^^^^ not found in this scope error[E0405]: cannot find trait `Sized` in this scope --> /Users/lmenezes/.cargo/registry/src/github.com-1ecc6299db9ec823/once_cell-1.16.0/src/imp_std.rs:293:12 | 293 | T: Sized, | ^^^^^ not found in this scope error[E0405]: cannot find trait `FnOnce` in this scope --> /Users/lmenezes/.cargo/registry/src/github.com-1ecc6299db9ec823/once_cell-1.16.0/src/imp_std.rs:291:52 | 291 | pub(crate) fn map_addr