没有NDK版本与要求的版本相符 [英] No version of NDK matched the requested version

查看:515
本文介绍了没有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,并且以前能够构建您的项目,但是由于出现错误没有NDK版本而开始失败"匹配到请求的版本",更新为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版本.通常,它安装在用户文件夹中的某个位置,然后至少在Windows中安装\AppData\Local\Android\Sdk\ndk\%ndk version%.

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 \AppData\Local\Android\Sdk\ndk\%ndk version% at least for Windows.

项目结构"对话框屏幕截图-来自Android Studio 3.6内部版本#AI-192.7142.36.36 .6200805,建于2020年2月12日

Project Structure dialog screenshot - from Android Studio 3.6 Build #AI-192.7142.36.36.6200805, built on February 12, 2020

执行选项1将为您编辑local.properties文件,并且在大多数情况下都可以使用.但是,根据此官方指南,您可以从模块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天全站免登陆