flutter
build_error
ai_generated
true
Gradle task assembleDebug failed with exit code 1: NDK version mismatch. Expected (23.1.7779620) but found (25.2.9519653)
ID: flutter/gradle-ndk-version-mismatch
80%Fix Rate
82%Confidence
1Evidence
2024-06-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Flutter 3.22.0 | active | — | — | — |
| Android Gradle Plugin 8.2.0 | active | — | — | — |
| NDK 23.1.7779620 | active | — | — | — |
Root Cause
The Android NDK version installed on the system does not match the version required by the Flutter project's native dependencies, causing compilation failures.
generic中文
系统上安装的 Android NDK 版本与 Flutter 项目原生依赖所需的版本不匹配,导致编译失败。
Official Documentation
https://developer.android.com/ndk/downloadsWorkarounds
-
85% success 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
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
-
75% success 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.
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.
-
80% success Use 'flutter config --android-ndk /path/to/correct/ndk' to point Flutter to a compatible NDK installation.
Use 'flutter config --android-ndk /path/to/correct/ndk' to point Flutter to a compatible NDK installation.
中文步骤
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
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.
Use 'flutter config --android-ndk /path/to/correct/ndk' to point Flutter to a compatible NDK installation.
Dead Ends
Common approaches that don't work:
-
Delete the entire .gradle directory and rebuild.
90% fail
Deleting .gradle only clears caches; the NDK version mismatch is a system-level configuration issue.
-
Set the NDK version in local.properties by force to the system version without adjusting dependencies.
70% fail
Forcing a different NDK version can break native library compilation if the C++ code relies on specific API levels.