没有与请求的版本匹配的 NDK 版本 [英] No version of NDK matched the requested version

查看:44
本文介绍了没有与请求的版本匹配的 NDK 版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新到 Android Gradle 插件 3.6.0(2020 年 2 月 24 日发布)后,多个项目独立开始失败:

After updating to Android Gradle plugin 3.6.0 (released Feb 24, 2020), several project independently started failing with:

No version of NDK matched the requested version 20.0.5594570. Versions available locally: 21.0.6113669

通过安装旧的预期 ndk 版本在本地修复"这个问题非常简单:

It's quite simple to "fix" this locally by installing the older expected ndk version:

sdkmanager 'ndk;20.0.5594570'

但是,我的问题是:这个旧版本在哪里以及如何指定?以及如何更新它以匹配最新版本 21.0.6113669?

However, my question is: Where and how is this older version specified? And how do I update it so it matches the latest version 21.0.6113669?

推荐答案

以下解决方案假设您当前使用的机器已安装 NDK,并且之前能够构建您的项目但开始失败并出现错误No version of ofNDK 匹配请求的版本"更新到 Android Gradle 插件 3.6.0 后.在继续之前,请确保已安装 NDK.

The following solutions assume that the machine you are using currently has NDK installed and was previously able to build your project but started failing with the error "No version of NDK matched the requested version" after updating to Android Gradle plugin 3.6.0. Before proceeding make sure to have NDK installed.

您只需在项目结构对话框

您可以通过单击 File > 打开 Project Structure 对话框.项目结构... 或按热键 CTRL + ALT + SHIFT + S(在 Windows 上)

You can open the Project Structure Dialog by clicking File > Project Structure... or by pressing the hotkeys CTRL + ALT + SHIFT + S (on windows)

打开项目结构对话框后,转到 SDK 位置,然后在 Android NDK 位置 下选择您本地安装的 NDK 版本.通常,它安装在您的用户文件夹中的某个位置,然后 AppDataLocalAndroidSdk dk\%ndk version% 至少对于 Windows.

Once the Project Structure Dialog is open, go to SDK Location and select your locally installed version of NDK under Android NDK Location. Typically this is installed somewhere in your user folder then AppDataLocalAndroidSdk dk\%ndk version% at least for Windows.

- 来自 Android Studio 3.6 Build #AI-192.7142.36.36.6200805,已构建2020 年 2 月 12 日

- from Android Studio 3.6 Build #AI-192.7142.36.36.6200805, built on February 12, 2020

执行选项 1 将为您编辑 local.properties 文件,并且在大多数情况下都可以使用.但是,如果您想在构建项目的所有机器上使用一致的 NDK 版本,根据 这个官方指南,你可以从你的模块 gradle 脚本中配置它.只需像这样在模块 gradle 脚本的 android{} 块中添加 ndkVersion.

Doing option 1 will edit your local.properties file for you and will work in most cases. But if you want to use a consistent NDK version on all machines you build the project with, according to this official guide, you can configure it from your module gradle script. Simply add the ndkVersion in your module gradle script's android{} block like so.

android {
    ndkVersion "major.minor.build"
}

将双引号之间的字符串替换为您要使用的 NDK 版本

replacing the string between the doublequotes with the NDK version you want to use

如果您希望在特定机器上构建的所有项目都使用相同的 NDK 版本,您还可以将 ANDROID_NDK_HOME 环境变量设置为 NDK 文件夹的路径.

If you want all projects built on a particular machine to use the same NDK version, you can also set ANDROID_NDK_HOME environment variable with the path to the NDK folder.

这篇关于没有与请求的版本匹配的 NDK 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆