After updating to Android Gradle plugin 3.6.0
(released Feb 24, 2020), several project independently started failing with:
No v
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.
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
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
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.
To answer the part of your question not answered by others, "Where and how is this older version specified? And how do I update it so it matches the latest version 21.0.6113669?":
The default version is set by the Android Gradle plugin. Each version will default to whatever version of the NDK that we used during testing to guarantee the best possible compatibility.
The difference between this and earlier plugin versions is that it used to happily use any NDK that you happened to have installed. This caused a ton of "works on my machine" issues for users where their co-workers couldn't build the project, it wouldn't work on CI but would locally, etc. It wasn't a good situation.
You can pick a specific version of the NDK to use in your project by setting android.ndkVersion
in your build.gradle. if you don't, it'll try to use the default version for the Gradle plugin that you're using.
The annoying bit is that most versions (until 4.1) will not automatically download the default version, which gives you the error you're seeing. If you explicitly pick a version in your build.gradle it actually will download automatically, and with 4.1 it will automatically download the default version too.
A thing that often confuses people is why this hits them when they're not using the NDK, or at least believe they are not. The answer in that case is that one of your dependencies includes native libraries and these need to be stripped before they are packed into the APK to keep size down, and strip
comes from the NDK.
After upgrading to gradle:3.6.0 (or later). Try renaming or deleting the ndk and ndk-bundle folders located in C:\Users\<user>\AppData\Local\Android\Sdk
Credit goes to: https://github.com/gradle/gradle/issues/12440#issuecomment-601214647
In the last version of Gradle there is no need to define the NDK versión inside the build.grade
:
android {
...
ndkVersion "21.0.6352462"
...
}
We must install the suggested versión
or define the current available version into the Android NDK Location:
i had same problem, after a while i found a temporary solution.
rename ndk
folder to ndk-bundle
.
in your projects go to local.properties
file and add this line before sdk.dir
:
ndk.dir=<path to your ndk folder>
its mine:
ndk.dir=G\:\\SDK\\ndk-bundle
sdk.dir=G\:\\SDK
i hope it help you