# Invalid argument(s): 无法加载原生库: /data/app/.../lib/arm64/libflutter.so: ABI 版本不兼容

- **ID:** `flutter/incompatible-abi-version`
- **领域:** flutter
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

Flutter 引擎原生库 (libflutter.so) 是为与设备 CPU 架构不同的 Android ABI 编译的，通常是由于使用错误的目标平台构建或 NDK 版本不匹配。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Flutter 3.16.0 | active | — | — |
| Flutter 3.22.0 | active | — | — |
| Android NDK r25c | active | — | — |

## 解决方案

1. ```
   运行 'flutter clean' 并使用正确的目标平台重新构建。对于 ARM64 设备，使用 'flutter build apk --target-platform android-arm64'。示例：
  flutter clean
  flutter build apk --target-platform android-arm64 --release
   ```
2. ```
   更新 Android NDK 版本以匹配 Flutter 要求。在 android/app/build.gradle 中设置：
  ndkVersion "25.1.8937393"
然后运行 'flutter clean' 并重新构建。
   ```
3. ```
   在 android/app/build.gradle 中启用 ABI 分割，为每个 ABI 生成单独的 APK：
  android {
    splits {
      abi {
        enable true
        reset()
        include 'arm64-v8a', 'armeabi-v7a', 'x86_64'
      }
    }
  }
   ```

## 无效尝试

- **Set 'android:extractNativeLibs="true"' in AndroidManifest.xml** — This flag controls APK packaging but does not fix the ABI mismatch; the library still has the wrong ABI. (80% 失败率)
- **Add all ABIs to the build.gradle abiFilters** — Including all ABIs increases APK size but doesn't resolve an incompatible ABI; the device still gets the wrong library if the build targets a different ABI. (60% 失败率)
- **Delete the build folder and rebuild without cleaning** — Without cleaning, the stale library persists; 'flutter clean' is required to remove the cached native libraries. (70% 失败率)
