最全解决办法: No version of NDK matched the requested version 20.0.5594570

2022-07-19 09:49:16

NDK环境变量配置

android studio更新到3.6,构建NDK项目的时候NDK版本引起的同步报错

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

方法1(Android Studio环境)

您只需在“项目结构”对话框中选择本地安装的NDK
You can open the Project Structure Dialog by clicking File > Project Structure… or by pressing the hotkeys CTRL + ALT + SHIFT + S (on 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 \AppData\Local\Android\Sdk\ndk%ndk version% at least for Windows.
Project Structure dialog screenshot - from Android Studio 3.6 Build #AI-192.7142.36.36.6200805, built on February 12, 2020
在这里插入图片描述在这里插入图片描述
Android NDK location
This location will be saved as ndk.dir property in the local.properties file.

D:\Android\Sdk\ndk\20.0.5594570

方法2 (官方推荐方法)

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版本替换双引号之间的字符串,例如:

android{
    ndkVersion"21.1.6352462"}

方法3 (官方不推荐的方法)

本人采用该方法!!!
WARNING: Support for ANDROID_NDK_HOME is deprecated and will be removed in the future. Use android.ndkVersion in build.gradle instead.
Support for ANDROID_NDK_HOME is deprecated and will be removed in the future. Use android.ndkVersion in build.gradle instead.

Linux环境:

sudo vim /etc/profile

最末尾添加如下环境变量:

export ANDROID_HOME=/home/user/android-sdkexport PATH=$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$PATHexport PATH=$ANDROID_HOME/build-tools/29.0.3:$PATH

**export ANDROID_NDK_HOME=/home/user/android-sdk/ndk/21.1.6352462/export PATH=$PATH:$ANDROID_NDK_HOME**

参考
Android没有NDK版本与要求的版本相符
https://mlog.club/article/5271812

  • 作者:呈叙墨客
  • 原文链接:https://blog.csdn.net/mowwwcom/article/details/106852156
    更新时间:2022-07-19 09:49:16