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

Can not build generated templates for Android (=armv7-a"" was unexpected at this time.) #302

Open
Pandicon opened this issue Mar 28, 2024 · 1 comment

Comments

@Pandicon
Copy link

Describe the bug
The generated templates code doesn't build for Android.

Steps To Reproduce
Follow the Readme and https://hackmd.io/XIcEwk4GSxy8APZhSa0UnA?view to set up cargo-mobile. Initialise a project with the egui (or any other) template. Try to build it for android (cargo mobile android apk build).

Expected behavior
The template builds (because it does build for desktop, so I suppose it should be fully functional)

Screenshots
None

Platform and Versions (please complete the following information):
Host OS: Windows 10
Target OS: Android
Rustc: 1.77
Ouput of cargo mobile doctor:

[✔] cargo-mobile v0.11.1
    • Contains commits up to "fix: fix creating a new `bevy` project (#297)\n"
    • Installed at "C:\\Users\\Uzivatel\\.cargo\\.cargo-mobile2"
    • Windows 10 v10.0
    • rustc v1.77.0 (aedd173a2 2024-3-17)

[✔] Android developer tools
    • SDK v26.1.1 installed at "C:\\Users\\Uzivatel\\AppData\\Local\\Android\\Sdk"
    • NDK v25.0.8775105 installed at "C:\\Users\\Uzivatel\\AppData\\Local\\Android\\Sdk\\ndk\\25.0.8775105"

[✔] Connected devices
    • No connected devices were found

Additional context
I am getting a nasty linker(?) error, here is the output when I try to build the egui template project:

C:\Users\Uzivatel\Documents\rust-mobile-tests\egui-mobile-test3>cargo mobile android apk build
Building universal APK for aarch64, armv7, i686, x86_64 ...

    Finished dev [unoptimized + debuginfo] target(s) in 0.81s
   Compiling egui-mobile-test3 v0.1.0 (C:\Users\Uzivatel\Documents\rust-mobile-tests\egui-mobile-test3)
error: linking with `C:\Users\Uzivatel\AppData\Local\Android\Sdk\ndk-bundle\toolchains/llvm/prebuilt/windows-x86_64\bin\armv7a-linux-androideabi24-clang.cmd` failed: exit code: 255
  |
  = note: "C:\\Users\\Uzivatel\\AppData\\Local\\Android\\Sdk\\ndk-bundle\\toolchains/llvm/prebuilt/windows-x86_64\\bin\\armv7a-linux-androideabi24-clang.cmd" "-march=armv7-a" "C:\\Users\\Uzivatel\\AppData\\Local\\Temp\\rustcfqnFHL\\symbols.o" "C:\\Users\\Uzivatel\\Documents\\rust-mobile-tests\\egui-mobile-test3\\target\\armv7-linux-androideabi\\debug\\deps\\egui_mobile_test3_desktop-90c90fdc842c3403.3c1u1nc7dyyz51t9.rcgu.o" "C:\\Users\\Uzivatel\\Documents\\rust-mobile-tests\\egui-mobile-test3\\target\\armv7-linux-androideabi\\debug\\deps\\egui_mobile_test3_desktop-90c90fdc842c3403.3st0pztv43grerm3.rcgu.o" "C:\\Users\\Uzivatel\\Documents\\rust-mobile-tests\\egui-mobile-test3\\target\\armv7-linux-androideabi\\debug\\deps\\egui_mobile_test3_desktop-90c90fdc842c3403.4mzo04mqwpb0ykrs.rcgu.o" "C:\\Users\\Uzivatel\\Documents\\rust-mobile-tests\\egui-mobile-test3\\target\\armv7-linux-androideabi\\debug\\deps\\egui_mobile_test3_desktop-90c90fdc842c3403.4voayt7mcsafickn.rcgu.o" "C:\\Users\\Uzivatel\\Documents\\rust-mobile-tests\\egui-mobile-test3\\target\\armv7-linux-androideabi\\debug\\deps\\egui_mobile_test3_desktop-90c90fdc842c3403.zsdacg79zidozd5.rcgu.o" "C:\\Users\\Uzivatel\\Documents\\rust-mobile-tests\\egui-mobile-test3\\target\\armv7-linux-androideabi\\debug\\deps\\egui_mobile_test3_desktop-90c90fdc842c3403.5dywr85bcmt0b4hc.rcgu.o" "-Wl,--as-needed" "-L" "C:\\Users\\Uzivatel\\Documents\\rust-mobile-tests\\egui-mobile-test3\\target\\armv7-linux-androideabi\\debug\\deps" "-L" "C:\\Users\\Uzivatel\\Documents\\rust-mobile-tests\\egui-mobile-test3\\target\\debug\\deps" "-L" "\"C:\\Users\\Uzivatel\\Documents\\rust-mobile-tests\\egui-mobile-test3\\.cargo\"" "-L" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib" "-Wl,-Bstatic" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libstd-067f9832e096d842.rlib" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libpanic_unwind-f7c17e26bc10799a.rlib" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libobject-190df1bd56239338.rlib" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libmemchr-9e7a35bffc71a4c9.rlib" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libaddr2line-db7b73ce4b785bdf.rlib" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libgimli-60d4f0d12b89972a.rlib" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\librustc_demangle-7442f1e2a27dea94.rlib" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libstd_detect-389991dd8b471902.rlib" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libhashbrown-3045767c4db452a2.rlib" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\librustc_std_workspace_alloc-fc9acb1a32bc8b19.rlib" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libminiz_oxide-96afb72d09101906.rlib" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libadler-b530ef553685576e.rlib" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libunwind-d229d36e08cca14e.rlib" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libcfg_if-6ebb5d8336137070.rlib" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\liblibc-0761201b1ceed43e.rlib" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\liballoc-8515fbf35f2ad340.rlib" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\librustc_std_workspace_core-f830a636083199b9.rlib" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libcore-1f05a6f5a4c17e73.rlib" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libcompiler_builtins-a5fa3da7ffc96b4b.rlib" "-Wl,-Bdynamic" "-ldl" "-llog" "-lunwind" "-ldl" "-lm" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "C:\\Users\\Uzivatel\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib" "-o" "C:\\Users\\Uzivatel\\Documents\\rust-mobile-tests\\egui-mobile-test3\\target\\armv7-linux-androideabi\\debug\\deps\\egui_mobile_test3_desktop-90c90fdc842c3403" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-landroid" "-llog" "-lOpenSLES"
  = note: =armv7-a"" was unexpected at this time.


error: could not compile `egui-mobile-test3` (bin "egui-mobile-test3-desktop") due to 1 previous error
error: Failed to compile lib
    `Failed to run `cargo build`: command ["cargo", "build", "--package",
    "egui-mobile-test3", "--manifest-path", "C:\\Users\\Uzivatel\\Documents\
    \rust-mobile-tests\\egui-mobile-test3\\Cargo.toml", "--target",
    "armv7-linux-androideabi"] exited with code 101

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:rustBuildArmDebug'.
> Process 'command 'cargo'' 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.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.4/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD FAILED in 8s
error: Failed to assemble APK
    command ["C:\\Users\\Uzivatel\\Documents\\rust-mobile-tests\\egui-mobile-test3\\gen\\android\\gradlew.bat",
    "--project-dir", "C:\\Users\\Uzivatel\\Documents\\rust-mobile-tests\\egui-mobile-test3\\gen\\android"] exited with
    code 1

I was also able to get it "running" on an emulated Google Pixel 3 (it did however hang and crash right after launch, but it at least built), but the target was apparently i686-linux-android. This leads me to suspect that the issue is with the armv7-a target specifically.
I believe I installed all of the required tools with the correct versions, but if there is a way to check if cargo-mobile is using the intended versions I am happy to do so.
I have very little experience with building Android apps, I usually did it through Unity, and that was already painful enough for me :D

@Pandicon
Copy link
Author

Pandicon commented Mar 29, 2024

Ok, so using this modification: android/ndk#1856 (comment) it now works.
But maybe it could be documented in https://hackmd.io/XIcEwk4GSxy8APZhSa0UnA, or better yet the README?
Or maybe don't recommend the broken NDK v25, unless that is in some way crucial for the tool? The issue was apparently fixed in NDK v27.

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

1 participant