fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.23k stars 291 forks source link

Failed to find ar for aarch64-linux-android in :C:\xxx\Android\Sdk\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\bin #1962

Closed ljyh223 closed 5 months ago

ljyh223 commented 5 months ago

Describe the bug

Hello, when I ran the example on the official website, an error occurred.

Sorry, I may be a bit dense, I'll try to be as descriptive as possible

Failed to find ar for aarch64-linux-android in C:\Users\jinch\AppData\Local\Android\Sdk\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\bin

The ndk in the SDK is already installed 图片

Steps to reproduce

Follow the steps on the official website

cargo install 'flutter_rust_bridge_codegen@^2.0.0-dev.0'
flutter_rust_bridge_codegen create my_app
flutter run

The commands were also installed normally and successfully. Then running ·lutter run gives the following error

Logs

Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
Resolving dependencies...
  flutter_lints 3.0.2 (4.0.0 available)
  leak_tracker 10.0.0 (10.0.5 available)
  leak_tracker_flutter_testing 2.0.1 (3.0.5 available)
  leak_tracker_testing 2.0.1 (3.0.1 available)
  lints 3.0.0 (4.0.0 available)
  material_color_utilities 0.8.0 (0.11.1 available)
  meta 1.11.0 (1.15.0 available)
  test_api 0.6.1 (0.7.1 available)
  vm_service 13.0.0 (14.2.2 available)
Got dependencies!
9 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
Launching lib\main.dart on 23013RK75C in debug mode...
Running Gradle task 'assembleDebug'...
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
ϵͳ�Ҳ���ָ����·����
ϵͳ�Ҳ���ָ����·����
ϵͳ�Ҳ���ָ�����ļ���
ϵͳ�Ҳ���ָ�����ļ���
Running pub get in "E:\code\flutter\flutter_rust\my_app\build\rust_lib_my_app\build\build_tool"
Resolving dependencies...
+ adaptive_number 1.0.0
+ args 2.4.2 (2.5.0 available)
+ async 2.11.0
+ build_tool 1.0.0 from path E:/code/flutter/flutter_rust/my_app/rust_builder/cargokit/build_tool
+ collection 1.18.0
+ convert 3.1.1
+ crypto 3.0.3
+ ed25519_edwards 0.3.1
+ fixnum 1.1.0
+ github 9.17.0 (9.24.0 available)
+ hex 0.2.0
+ http 1.1.0 (1.2.1 available)
+ http_parser 4.0.2
+ json_annotation 4.9.0
+ logging 1.2.0
+ meta 1.15.0
+ path 1.8.0 (1.9.0 available)
+ petitparser 5.4.0 (6.0.2 available)
+ source_span 1.10.0
+ string_scanner 1.2.0
+ term_glyph 1.2.1
+ toml 0.14.0 (0.15.0 available)
+ typed_data 1.3.2
+ version 3.0.0 (3.0.2 available)
+ yaml 3.1.2
Changed 25 dependencies!
7 packages have newer versions incompatible with dependency constraints.
Try `dart pub outdated` for more information.
Compiling bin/build_tool_runner.dart to kernel file bin/build_tool_runner.dill.
INFO: Precompiled binaries are disabled
INFO: Building rust_lib_my_app for aarch64-linux-android
SEVERE: ================================================================================
SEVERE: Cargokit BuildTool failed with error:
SEVERE: --------------------------------------------------------------------------------
SEVERE: Exception: Failed to find ar for aarch64-linux-android in C:\Users\jinch\AppData\Local\Android\Sdk\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\bin
SEVERE: --------------------------------------------------------------------------------
SEVERE: #0      AndroidEnvironment.buildEnvironment (package:build_tool/src/android_environment.dart:109:7)
SEVERE: #1      RustBuilder._buildEnvironment (package:build_tool/src/builder.dart:195:18)
SEVERE: #2      RustBuilder.build (package:build_tool/src/builder.dart:160:26)
SEVERE: #3      ArtifactProvider.getArtifacts (package:build_tool/src/artifacts_provider.dart:71:39)
SEVERE: <asynchronous suspension>
SEVERE: #4      BuildGradle.build (package:build_tool/src/build_gradle.dart:35:23)
SEVERE: <asynchronous suspension>
SEVERE: #5      BuildGradleCommand.runBuildCommand (package:build_tool/src/build_tool.dart:65:5)
SEVERE: <asynchronous suspension>
SEVERE: #6      BuildCommand.run (package:build_tool/src/build_tool.dart:37:5)
SEVERE: <asynchronous suspension>
SEVERE: #7      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
SEVERE: <asynchronous suspension>
SEVERE: #8      runMain (package:build_tool/src/build_tool.dart:251:5)
SEVERE: <asynchronous suspension>
SEVERE: --------------------------------------------------------------------------------
SEVERE: BuildTool arguments: [build-gradle]
SEVERE: ================================================================================
[CXX1101] NDK at C:\Users\jinch\AppData\Local\Android\sdk\ndk\23.1.7779620 did not have a source.properties file
[CXX1101] NDK at C:\Users\jinch\AppData\Local\Android\sdk\ndk\23.1.7779620 did not have a source.properties file
[CXX1101] NDK at C:\Users\jinch\AppData\Local\Android\sdk\ndk\23.1.7779620 did not have a source.properties file
[CXX1101] NDK at C:\Users\jinch\AppData\Local\Android\sdk\ndk\23.1.7779620 did not have a source.properties file
√  Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app-debug.apk...
Debug service listening on ws://127.0.0.1:61974/0snWKJtBN1Y=/ws
Syncing files to device 23013RK75C...
E/flutter (23873): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to load dynamic library 'librust_lib_my_app.so': dlopen failed: library "librust_lib_my_app.so" not found
E/flutter (23873): #0      _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:11:43)
E/flutter (23873): #1      new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:22:12)
E/flutter (23873): #2      new ExternalLibrary.open (package:flutter_rust_bridge/src/platform_types/_io.dart:39:47)
E/flutter (23873): #3      loadExternalLibraryRaw (package:flutter_rust_bridge/src/loader/_io.dart:56:28)
E/flutter (23873): #4      loadExternalLibrary (package:flutter_rust_bridge/src/loader/_io.dart:14:10)
E/flutter (23873): #5      BaseEntrypoint._loadDefaultExternalLibrary (package:flutter_rust_bridge/src/main_components/entrypoint.dart:129:13)
E/flutter (23873): #6      BaseEntrypoint.initImpl (package:flutter_rust_bridge/src/main_components/entrypoint.dart:48:31)
E/flutter (23873): #7      RustLib.init (package:my_app/src/rust/frb_generated.dart:25:20)
E/flutter (23873): #8      main (package:my_app/main.dart:6:17)
E/flutter (23873): #9      _runMain.<anonymous closure> (dart:ui/hooks.dart:301:23)
E/flutter (23873): #10     _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
E/flutter (23873): #11     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
E/flutter (23873): 
I/.example.my_app(23873): ProcessProfilingInfo new_methods=1070 is saved saved_to_disk=1 resolve_classes_delay=8000
I/.example.my_app(23873): This is non sticky GC, maxfree is 33554432 minfree is 8388608
W/FinalizerDaemon(23873): type=1400 audit(0.0:78156): avc:  denied  { getopt } for  path="/dev/socket/usap_pool_primary" scontext=u:r:untrusted_app_32:s0:c59,c257,c512,c768 tcontext=u:r:zygote:s0 tclass=unix_stream_socket permissive=0 app=com.example.my_app
W/.example.my_app(23873): ApkAssets: Deleting an ApkAssets object '<empty> and /product/app/MiuiContentCatcherMIUI15/MiuiContentCatcherMIUI15.apk' with 1 weak references
W/.example.my_app(23873): ApkAssets: Deleting an ApkAssets object '<empty> and /system_ext/priv-app/RtMiCloudSDK/RtMiCloudSDK.apk' with 1 weak references
W/.example.my_app(23873): ApkAssets: Deleting an ApkAssets object '<empty> and /system_ext/app/miuisystem/miuisystem.apk' with 1 weak references

Flutter Doctor

PS E:\code\flutter\flutter_rust> flutter doctor
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust
this source!
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel stable, 3.19.6, on Microsoft Windows [版本 10.0.22631.3593], locale
    zh-CN)
    ! Warning: `flutter` on your path resolves to
      D:\scoop\apps\flutter-cn\3.19.6\bin\flutter, which is not inside your current Flutter
      SDK checkout at D:\scoop\apps\flutter-cn\current. Consider adding
      D:\scoop\apps\flutter-cn\current\bin to the front of your path.
    ! Warning: `dart` on your path resolves to D:\scoop\apps\flutter-cn\3.19.6\bin\dart,
      which is not inside your current Flutter SDK checkout at
      D:\scoop\apps\flutter-cn\current. Consider adding D:\scoop\apps\flutter-cn\current\bin
      to the front of your path.
[✓] Windows Version (Installed version of Windows is version 10 or higher)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✗] Chrome - develop for the web (Cannot find Chrome executable at
    .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.6)
[✓] Android Studio (version 2023.3)
[✓] IntelliJ IDEA Community Edition (version 2024.1)
[✓] Connected device (3 available)
[✓] Network resources

! Doctor found issues in 2 categories.

### Expected behavior

By running the official website example and running successfully

### Generated binding code

_No response_

### OS

window 11

### Version of `flutter_rust_bridge_codegen`

2.0.0-dev.35

### Flutter info

```shell
PS E:\code\flutter\flutter_rust> flutter doctor -v
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust
this source!
[!] Flutter (Channel stable, 3.19.6, on Microsoft Windows [版本 10.0.22631.3593], locale
    zh-CN)
    • Flutter version 3.19.6 on channel stable at D:\scoop\apps\flutter-cn\current
    ! Warning: `flutter` on your path resolves to
      D:\scoop\apps\flutter-cn\3.19.6\bin\flutter, which is not inside your current Flutter
      SDK checkout at D:\scoop\apps\flutter-cn\current. Consider adding
      D:\scoop\apps\flutter-cn\current\bin to the front of your path.
    ! Warning: `dart` on your path resolves to D:\scoop\apps\flutter-cn\3.19.6\bin\dart,
      which is not inside your current Flutter SDK checkout at
      D:\scoop\apps\flutter-cn\current. Consider adding D:\scoop\apps\flutter-cn\current\bin
      to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (5 weeks ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn
    • If those were intentional, you can disregard the above warnings; however it is
      recommended to use "git" directly to perform update checks and upgrades.

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Users\jinch\AppData\Local\Android\sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: D:\Android-studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0--11572160)
    • All Android licenses accepted.

[✗] Chrome - develop for the web (Cannot find Chrome executable at
    .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.6)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.9.34728.123
    • Windows 10 SDK version 10.0.22621.0

[✓] Android Studio (version 2023.3)
    • Android Studio at D:\Android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.10+0--11572160)

[✓] IntelliJ IDEA Community Edition (version 2024.1)
    • IntelliJ at D:\IntelliJ IDEA Community Edition 2024.1.1
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] Connected device (3 available)
    • 23013RK75C (mobile) • 2df08b32 • android-arm64  • Android 14 (API 34)
    • Windows (desktop)   • windows  • windows-x64    • Microsoft Windows [版本
      10.0.22631.3593]
    • Edge (web)          • edge     • web-javascript • Microsoft Edge 125.0.2535.51

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.

Version of clang++

clang version 18.1.5 Target: x86_64-pc-windows-msvc Thread model: posix InstalledDir: D:\scoop\apps\llvm\current\bin

Additional context

No response

welcome[bot] commented 5 months ago

Hi! Thanks for opening your first issue here! :smile:

fzyzcjy commented 5 months ago

So looks like the problem is

SEVERE: Cargokit BuildTool failed with error:
SEVERE: --------------------------------------------------------------------------------
SEVERE: Exception: Failed to find ar for aarch64-linux-android in C:\Users\jinch\AppData\Local\Android\Sdk\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\bin

what about fixing it (e.g. maybe rustup add that toolchain).

In addition, flutter run --verbose may help since it outputs more

ljyh223 commented 5 months ago

I tried the rustup target add aarch64-linux-android method. Could you please give me more details?

PS C:\Users\jinch> rustup target add aarch64-linux-android
info: component 'rust-std' for target 'aarch64-linux-android' is up to date
PS C:\Users\jinch> rustup target list
aarch64-apple-darwin
aarch64-apple-ios
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-linux-ohos
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
armv7-unknown-linux-ohos
armv7a-none-eabi
armv7r-none-eabi
armv7r-none-eabihf
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
loongarch64-unknown-linux-gnu
loongarch64-unknown-none
loongarch64-unknown-none-softfloat
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
x86_64-apple-ios
x86_64-fortanix-unknown-sgx
x86_64-linux-android
x86_64-pc-solaris
x86_64-pc-windows-gnu
x86_64-pc-windows-msvc (installed)
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-linux-ohos
x86_64-unknown-netbsd
x86_64-unknown-none
x86_64-unknown-redox
x86_64-unknown-uefi
ljyh223 commented 5 months ago

I'm so sorry, this is my first time using github issues!

fzyzcjy commented 5 months ago

Maybe try to show logs of flutter run --verbose

ljyh223 commented 5 months ago

Thanks anyway, I solved it by reinstalling android ndk

ljyh223 commented 5 months ago

Thanks anyway, I solved it by reinstalling android ndk

fzyzcjy commented 5 months ago

Happy to see it is solved! Then I will close the issue. Feel free to reopen if having any questions

github-actions[bot] commented 4 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.