# Gradle 任务 assembleDebug 失败，退出码 1：NDK 版本不匹配。期望 (23.1.7779620) 但发现 (25.2.9519653)

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

## 根因

系统上安装的 Android NDK 版本与 Flutter 项目原生依赖所需的版本不匹配，导致编译失败。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Flutter 3.22.0 | active | — | — |
| Android Gradle Plugin 8.2.0 | active | — | — |
| NDK 23.1.7779620 | active | — | — |

## 解决方案

1. ```
   Install the required NDK version via Android Studio SDK Manager or command line: sdkmanager 'ndk;23.1.7779620'. Then update android/gradle.properties: android.ndkVersion=23.1.7779620
   ```
2. ```
   If you cannot install the exact version, modify the project's build.gradle to use the system NDK version and update any native dependencies that require the specific version. Example: ndkVersion = '25.2.9519653' in android/app/build.gradle, then test compatibility.
   ```
3. ```
   Use 'flutter config --android-ndk /path/to/correct/ndk' to point Flutter to a compatible NDK installation.
   ```

## 无效尝试

- **Delete the entire .gradle directory and rebuild.** — Deleting .gradle only clears caches; the NDK version mismatch is a system-level configuration issue. (90% 失败率)
- **Set the NDK version in local.properties by force to the system version without adjusting dependencies.** — Forcing a different NDK version can break native library compilation if the C++ code relies on specific API levels. (70% 失败率)
