解决 Flutter:ndkVersion 识别错误

解决 Flutter:ndkVersion 识别错误

报错日志

Your project is configured with Android NDK 26.3.11579264, but the following plugin(s) depend on a different Android NDK version:
- flutter_native_splash requires Android NDK 27.0.12077973
Fix this issue by using the highest Android NDK version (they are backward compatible).
Add the following to D:\project\flutter\SoyPanel\android\app\build.gradle.kts:

    android {
        ndkVersion = "27.0.12077973"
        ...
    }

报错说明

安装了 NDK 27.0.12077973,但 Flutter 识别为旧的 26.3.11579264,这通常是因为 项目默认使用 SDK 中设置的 NDK 版本

步骤 1:确认 NDK 27 已正确安装

打开 SDK Manager - SDK Tools - 勾选 Show Package Details - 列表找到 NDK 并选择:27.0.12077973
这里以 27.0.12077973 作为示例,按你输出报错选择对应的版本既可

步骤 2:在 build.gradle.kts 中明确指定 NDK 版本

编辑你的 android/app/build.gradle.kts,在 android {} 块中添加(或修改)
注意:如果你改的是 build.gradle 而不是 build.gradle.kts(即 Groovy 而不是 Kotlin),语法是一样的。

android {
    ndkVersion = "27.0.12077973"
}

步骤 3:清除缓存并重启构建

flutter clean
flutter pub get
flutter build apk

额外提示(可选):

你也可以在全局环境变量中设置 NDK 路径(如果你使用的是外部 NDK):

export ANDROID_NDK_HOME=/path/to/ndk/27.0.12077973
茶馆

MySQL Workbench 点击 Server Status面板:Could not acquire management access for administration 报错问题

2025-2-23 22:21:48

茶馆

如何安装 JDK 8 / 11

2025-4-14 0:34:43

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
❯
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索