# Invalid argument(s): Could not load native library: incompatible ABI version

- **ID:** `flutter/dart-ffi-abi-mismatch`
- **Domain:** flutter
- **Category:** build_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Flutter 3.7.0 | active | — | — |
| Flutter 3.10.6 | active | — | — |
| Android NDK r25c | active | — | — |
| Android NDK r23b | active | — | — |

## Workarounds

1. **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.** (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.
   ```
2. **Use a consistent NDK version across the project by setting android.ndkVersion in android/gradle.properties, e.g., ndkVersion = '23.1.7779620'** (85% success)
   ```
   Use a consistent NDK version across the project by setting android.ndkVersion in android/gradle.properties, e.g., ndkVersion = '23.1.7779620'
   ```
3. **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)** (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)
   ```

## Dead Ends

- **Add all ABI filters to build.gradle: ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'** — This includes unsupported ABIs and may cause crashes on devices that don't support them; the real issue is a mismatch, not missing ABIs. (70% fail)
- **Recompile the native library with the same NDK version as Flutter's bundled NDK** — Flutter does not bundle a fixed NDK; the version depends on the Android SDK installation. This fix may break after SDK updates. (55% fail)
- **Set minSdkVersion to 21 to force 64-bit only** — This does not resolve ABI versioning issues; it only restricts the device set and may exclude older devices. (80% fail)
