# ArgumentError：无效参数：无法加载动态库 'libnative.so'：dlopen 失败：未找到库 "libnative.so"

- **ID:** `flutter/dart-ffi-library-not-found`
- **领域:** flutter
- **类别:** module_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

Dart FFI 绑定引用的原生共享库未随应用打包，或未放置在目标平台的正确目录中（Android jniLibs、iOS Frameworks 或 Linux/MacOS 库路径）。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Flutter 3.7 | active | — | — |
| Dart 3.0 | active | — | — |
| Android 12 | active | — | — |
| iOS 15 | active | — | — |
| Linux | active | — | — |

## 解决方案

1. ```
   Place the shared library in the correct platform-specific directory: android/app/src/main/jniLibs/<abi>/ for Android, or use a Flutter plugin with native code.
   ```
2. ```
   Use the ffi package's DynamicLibrary.process() to load symbols from the main process if the library is linked at compile time.
   ```

## 无效尝试

- **** — Assets are not loaded as shared libraries; FFI requires the library to be in the system library path or bundled as a native dependency. (80% 失败率)
- **** — FFI resolves library paths from the system loader, not the Dart script's location; relative paths are platform-dependent and often fail. (70% 失败率)
- **** — On mobile platforms (Android/iOS), environment variables are not accessible to the app process; this only works on desktop. (60% 失败率)
