Invalid argument(s): Could not load native library: incompatible ABI version
ID: flutter/dart-ffi-abi-mismatch
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Flutter 3.7.0 | active | — | — | — |
| Flutter 3.10.6 | active | — | — | — |
| Android NDK r25c | active | — | — | — |
| Android NDK r23b | active | — | — | — |
Root Cause
The native library (.so file) was compiled for a different Android ABI (e.g., arm64-v8a vs armeabi-v7a) than the device's architecture, or the NDK version used to compile the library is incompatible with the Flutter engine's NDK.
generic中文
原生库(.so文件)是针对与设备架构不同的Android ABI(例如arm64-v8a与armeabi-v7a)编译的,或者用于编译库的NDK版本与Flutter引擎的NDK不兼容。
Official Documentation
https://docs.flutter.dev/development/platform-integration/c-interopWorkarounds
-
90% success Specify the correct ABI filter in android/app/build.gradle under defaultConfig: ndk { abiFilters 'arm64-v8a', 'armeabi-v7a' } and ensure the .so files are placed in the correct jniLibs directory structure.
Specify the correct ABI filter in android/app/build.gradle under defaultConfig: ndk { abiFilters 'arm64-v8a', 'armeabi-v7a' } and ensure the .so files are placed in the correct jniLibs directory structure. -
85% success Use a consistent NDK version across the project by setting android.ndkVersion in android/gradle.properties, e.g., ndkVersion = '23.1.7779620'
Use a consistent NDK version across the project by setting android.ndkVersion in android/gradle.properties, e.g., ndkVersion = '23.1.7779620'
-
80% success If using a prebuilt library, verify the ABI with readelf -A lib.so and match it to the target device's architecture (e.g., arm64-v8a for 64-bit ARM)
If using a prebuilt library, verify the ABI with readelf -A lib.so and match it to the target device's architecture (e.g., arm64-v8a for 64-bit ARM)
中文步骤
Specify the correct ABI filter in android/app/build.gradle under defaultConfig: ndk { abiFilters 'arm64-v8a', 'armeabi-v7a' } and ensure the .so files are placed in the correct jniLibs directory structure.Use a consistent NDK version across the project by setting android.ndkVersion in android/gradle.properties, e.g., ndkVersion = '23.1.7779620'
If using a prebuilt library, verify the ABI with readelf -A lib.so and match it to the target device's architecture (e.g., arm64-v8a for 64-bit ARM)
Dead Ends
Common approaches that don't work:
-
Add all ABI filters to build.gradle: ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'
70% fail
This includes unsupported ABIs and may cause crashes on devices that don't support them; the real issue is a mismatch, not missing ABIs.
-
Recompile the native library with the same NDK version as Flutter's bundled NDK
55% fail
Flutter does not bundle a fixed NDK; the version depends on the Android SDK installation. This fix may break after SDK updates.
-
Set minSdkVersion to 21 to force 64-bit only
80% fail
This does not resolve ABI versioning issues; it only restricts the device set and may exclude older devices.