[bug] Cannot build for android
Describe the bug
When packaging for android, tauri-cli tries to build for armv7. Actually I don't need that target, but don't know how to turn it off neither. It finds the right linker in the Android NDK - armv7a-linux-androideabi24-clang.cmd, but adds param -march=armv7-a behind it. Cargo calls CMD to execute the link command, and CMD refuse a param like "-march=armv7-a". It just throws a line of error
=armv7-a"" was unexpected at this time.
The param -march=armv7-a comes from the armv7-linux-androideabi target of rustc.
https://github.com/rust-lang/rust/blob/master/compiler/rustc_target/src/spec/armv7_linux_androideabi.rs#L13
I don't know why it calls CMD, and don't know why it adds such a param, and even don't know how to remove it.
Reproduction
cargo tauri android build
If you feel it is complicated, start a cmd. Suppose your linker is %FOO%\armv7a-linux-androideabi24-clang.cmd, type
"%FOO%\\armv7a-linux-androideabi24-clang.cmd" "-march=armv7-a"
You will find that it works if you remove the quotes.
"%FOO%\\armv7a-linux-androideabi24-clang.cmd" -march=armv7-a
Expected behavior
Build successfully.
Or give us an option to disable armv7 target.
Platform and versions
Environment
› OS: Windows 10.0.22621 X64
› Webview2: 111.0.1661.41
› MSVC:
- Visual Studio Community 2022
› Node.js: 18.15.0
› npm: 9.5.0
› pnpm: Not installed!
› yarn: Not installed!
› rustup: 1.25.2
› rustc: 1.70.0-nightly
› cargo: 1.70.0-nightly
› Rust toolchain: nightly-x86_64-pc-windows-msvc
Packages
› @tauri-apps/cli [NPM]: 2.0.0-alpha.2
› @tauri-apps/api [NPM]: 1.2.0
› tauri [RUST]: git+https://github.com/tauri-apps/tauri.git?branch=next#6669f1659af2e6f1a1b81fb9f6524a9c688a887c (2.0.0-alpha.3) (no manifest),
› tauri-build [RUST]: git+https://github.com/tauri-apps/tauri.git?branch=next#6669f1659af2e6f1a1b81fb9f6524a9c688a887c (2.0.0-alpha.1) (no manifest),
› tao [RUST]: 0.18.1 (no manifest),
› wry [RUST]: 0.27.0 (no manifest),
App
› distDir: ../dist
› devPath: http://localhost:5173/
› framework: Vue.js
› bundler: Vite
App directory structure
├─ dist
├─ node_modules
├─ public
├─ src
└─ src-tauri
Stack trace
No response
Additional context
No response
I modified the generated project and removed armv7 arch. It is resolved temporarily.
I wasn't able to reproduce this at all with a new project, try recreating the project from scratch.
I've installed a new NDK and could still reproduce that. However I've found it an NDK issue. I've opened one for NDK: https://github.com/android/ndk/issues/1856
We're seeing this issue on CI: https://github.com/tauri-apps/tauri/actions/runs/4774744796/jobs/8488622948?pr=6708#step:13:783
I modified the generated project and removed armv7 arch. It is resolved temporarily.
@Berrysoft may I ask how you managed to remove the armv7 arch? I have the same problem and I'm new to android dev.
add "targetList=aarch64,x86_64" in gradle.properties
I choose to modify NDK following this comment: https://github.com/android/ndk/issues/1856#issuecomment-1542248775