tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[bug] Cannot build for android

Open Berrysoft opened this issue 2 years ago • 7 comments

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

Berrysoft avatar Mar 18 '23 18:03 Berrysoft

I modified the generated project and removed armv7 arch. It is resolved temporarily.

Berrysoft avatar Mar 21 '23 15:03 Berrysoft

I wasn't able to reproduce this at all with a new project, try recreating the project from scratch.

amrbashir avatar Mar 28 '23 14:03 amrbashir

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

Berrysoft avatar Mar 30 '23 13:03 Berrysoft

We're seeing this issue on CI: https://github.com/tauri-apps/tauri/actions/runs/4774744796/jobs/8488622948?pr=6708#step:13:783

lucasfernog avatar Apr 23 '23 12:04 lucasfernog

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.

c-antin avatar May 28 '23 14:05 c-antin

add "targetList=aarch64,x86_64" in gradle.properties

lazytiger avatar May 30 '23 10:05 lazytiger

I choose to modify NDK following this comment: https://github.com/android/ndk/issues/1856#issuecomment-1542248775

Berrysoft avatar May 30 '23 11:05 Berrysoft