flutter
module_error
ai_generated
true
Invalid argument(s): Failed to load dynamic library 'libmy_native.so': dlopen failed: library not found
ID: flutter/dart-ffi-missing-library
80%Fix Rate
88%Confidence
1Evidence
2024-01-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.13.0 | active | — | — | — |
| 3.16.0 | active | — | — | — |
| 3.22.0 | active | — | — | — |
Root Cause
The native library (.so file) is not bundled with the app or not placed in the correct ABI directory.
generic中文
本机库(.so 文件)未与应用捆绑或未放置在正确的 ABI 目录中。
Official Documentation
https://api.flutter.dev/flutter/dart-ffi/dart-ffi-library.htmlWorkarounds
-
85% success Place the .so files in the correct jniLibs directory structure (e.g., android/app/src/main/jniLibs/arm64-v8a/).
Place the .so files in the correct jniLibs directory structure (e.g., android/app/src/main/jniLibs/arm64-v8a/).
-
90% success Use the flutter_ffi plugin's built-in bundling mechanism by declaring the library in pubspec.yaml under 'ffi_native_libraries'.
Use the flutter_ffi plugin's built-in bundling mechanism by declaring the library in pubspec.yaml under 'ffi_native_libraries'.
-
80% success Configure Gradle to include the library by adding jniLibs sourceSets in android/app/build.gradle.
Configure Gradle to include the library by adding jniLibs sourceSets in android/app/build.gradle.
中文步骤
Place the .so files in the correct jniLibs directory structure (e.g., android/app/src/main/jniLibs/arm64-v8a/).
Use the flutter_ffi plugin's built-in bundling mechanism by declaring the library in pubspec.yaml under 'ffi_native_libraries'.
Configure Gradle to include the library by adding jniLibs sourceSets in android/app/build.gradle.
Dead Ends
Common approaches that don't work:
-
50% fail
Flutter's Gradle build does not automatically include libs/ unless jniLibs sourceSets are configured.
-
30% fail
Android will not load the library if the ABI does not match the device's architecture.
-
20% fail
Prevents extraction of native libs from APK; library file remains inaccessible at runtime.