-
Notifications
You must be signed in to change notification settings - Fork 350
Description
Describe the bug
Problem
I was going to make a bug report but I solved this issue myself after some time, and I just wanted to help anyone else who's having the same issue: If you set up the wrong Android NDK version, your build will fail:
Using hardware rendering with device sdk gphone64 x86 64. If you notice graphics artifacts, consider enabling software
rendering with "--enable-software-rendering".
Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
[2023-02-22T21:57:22Z INFO cargo_ndk::cli] Using NDK at path: C:\Users\Satvik\AppData\Local\Android\Sdk\ndk\25.2.9519653
[2023-02-22T21:57:22Z INFO cargo_ndk::cli] NDK API level: 21
[2023-02-22T21:57:22Z INFO cargo_ndk::cli] Building targets: armeabi-v7a, arm64-v8a, x86, x86_64
[2023-02-22T21:57:22Z INFO cargo_ndk::cli] Building armeabi-v7a (armv7-linux-androideabi)
Compiling dart-sys v4.0.2
Compiling allo-isolate v0.1.14
error: failed to run custom build command for `dart-sys v4.0.2`
Caused by:
process didn't exit successfully: `C:\Users\Satvik\Projects\Flutter\frbtest\native\target\debug\build\dart-sys-b6127720b54fd0e9\build-script-build` (exit code: 1)
--- stdout
TARGET = Some("armv7-linux-androideabi")
OPT_LEVEL = Some("0")
HOST = Some("x86_64-pc-windows-msvc")
cargo:rerun-if-env-changed=CC_armv7-linux-androideabi
CC_armv7-linux-androideabi = Some("C:\\Users\\Satvik\\AppData\\Local\\Android\\Sdk\\ndk\\25.2.9519653\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\armv7a-linux-androideabi21-clang.cmd")
cargo:rerun-if-env-changed=CFLAGS_armv7-linux-androideabi
CFLAGS_armv7-linux-androideabi = None
cargo:rerun-if-env-changed=CFLAGS_armv7_linux_androideabi
CFLAGS_armv7_linux_androideabi = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
running: "C:\\Users\\Satvik\\AppData\\Local\\Android\\Sdk\\ndk\\25.2.9519653\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\clang.exe" "--target=armv7a-linux-androideabi21" "-O0" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "--target=armv7-linux-androideabi" "-I" "C:\\Users\\Satvik\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\dart-sys-4.0.2\\dart-sdk\\include" "-Wall" "-Wextra" "-o" "C:\\Users\\Satvik\\Projects\\Flutter\\frbtest\\native\\target\\armv7-linux-androideabi\\debug\\build\\dart-sys-1ec97ebb3266014a\\out\\3a44bc21c067c7b4-dart_api_dl.o" "-c" "C:\\Users\\Satvik\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\dart-sys-4.0.2\\dart-sdk\\include\\dart_api_dl.c"
exit code: 0
cargo:rerun-if-env-changed=AR_armv7-linux-androideabi
AR_armv7-linux-androideabi = Some("C:\\Users\\Satvik\\AppData\\Local\\Android\\Sdk\\ndk\\25.2.9519653\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\arm-linux-androideabi-ar.exe")
cargo:rerun-if-env-changed=ARFLAGS_armv7-linux-androideabi
ARFLAGS_armv7-linux-androideabi = None
cargo:rerun-if-env-changed=ARFLAGS_armv7_linux_androideabi
ARFLAGS_armv7_linux_androideabi = None
cargo:rerun-if-env-changed=TARGET_ARFLAGS
TARGET_ARFLAGS = None
cargo:rerun-if-env-changed=ARFLAGS
ARFLAGS = None
running: "C:\\Users\\Satvik\\AppData\\Local\\Android\\Sdk\\ndk\\25.2.9519653\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\arm-linux-androideabi-ar.exe" "cq" "C:\\Users\\Satvik\\Projects\\Flutter\\frbtest\\native\\target\\armv7-linux-androideabi\\debug\\build\\dart-sys-1ec97ebb3266014a\\out\\libdart_api_dl.a" "C:\\Users\\Satvik\\Projects\\Flutter\\frbtest\\native\\target\\armv7-linux-androideabi\\debug\\build\\dart-sys-1ec97ebb3266014a\\out\\3a44bc21c067c7b4-dart_api_dl.o"
--- stderr
error occurred: Failed to find tool. Is `` installed? (see https://github.com/rust-lang/cc-rs#compile-time-requirements for help)
[2023-02-22T21:57:22Z INFO cargo_ndk::cli] If the build failed due to a missing target, you can run this command:
[2023-02-22T21:57:22Z INFO cargo_ndk::cli]
[2023-02-22T21:57:22Z INFO cargo_ndk::cli] rustup target install armv7-linux-androideabi
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:cargoBuildDebug'.
> Process 'command 'cargo'' finished with non-zero exit value 101
* 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 1s
Running Gradle task 'assembleDebug'... 2,616ms
Exception: Gradle task assembleDebug failed with exit code 1
Solution
The docs say to use Android Studio to download the NDK, but you can't choose the version on Android Studio. Instead, download it directly from the Android GitHub page: https://github.com/android/ndk/wiki/Unsupported-Downloads. I am using r22b and it works fine.
The docs also link to an issue in Rust, but it's been merged so I thought the issue was fixed and the latest NDK would work, but it still seems that it's not the case.
I recommend that the docs add this way of downloading the NDK so that people aren't stuck like I was for a while.
Codegen logs with RUST_LOG=debug
environment variable
NA since it's an Android issue, not a codegen issue.
To Reproduce
No response
Expected behavior
No response
Generated binding code
No response
OS
No response
Version of flutter_rust_bridge_codegen
No response
Flutter info
No response
Version of clang++
No response
Version of ffigen
No response
Additional context
No response