Android: No version of NDK matched the requested version

半世苍凉 提交于 2020-03-17 06:46:27

问题


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

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

sdkmanager 'ndk;20.0.5594570'

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?


回答1:


Option 1:

You can simply select your locally installed NDK in the Project Structure Dialog

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

Option 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"
}

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

Option 3:

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.




回答2:


I have the same issue. I resolved it through the SDK manager under SDK Tools, click Show Package Details and then scroll under NDK (Side by side) and tick and apply the version you need. See image below:

My question for anyone is, why do we need this now for projects that do not require the NDK? As it turns out the NDK is a pre-existing requirement in the project I work on for a dependency!




回答3:


I run into this too

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

Option 1:

You can simply select your locally installed NDK in the Project Structure Dialog works !

But is only valid for local builds, an I need a solution for CI

Option 2:

Doesn't works always

android {
    compileSdkVersion 28
    ndkVersion "21.0.6113669"
    ...
}

Here it seems not to work https://github.com/hannesa2/panoramagl/pull/17/checks with this change https://github.com/hannesa2/panoramagl/pull/17/files#diff-cff4e8c294a5dc5e76308662ae1ddcacR6-R7

Option 3:

export ANDROID_NDK_HOME=/Users/{my-user}/Development/adt/sdk/ndk/21.0.6113669

works too !




回答4:


Change your classpath version to 3.5.0 inside your build.gradle, project level.

dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
}

I have the same issue and it solved.



来源:https://stackoverflow.com/questions/60404457/android-no-version-of-ndk-matched-the-requested-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!