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?
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.
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.
- 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.
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!
It isn't necessary with Android gradle plugin > 4.1.0 (see also https://issuetracker.google.com/issues/144111441)
With < 4.1.0 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:
It's only works, when you specify it in every used module
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 as well !
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.
This worked for MacOS, check via Terminal:
cd ~/Library/Android/sdk
ls
If you see "ndk" and/or "ndk-bundle", delete them:
sudo rm -r ndk/
sudo rm -r ndk-bundle/
After deleting those folders, everything worked for me.
This is copied from GitHub
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:
replace gradle classpath with this in Project level build.gradle
classpath 'com.android.tools.build:gradle:4.1.0'
in gradle-wrapper.properties add this line
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
I faced the same problem. Then i found the developer references here
So, the problem start with gradle version 3.6. Before 3.6 there was no default ndk specified. So, any version of ndk worked without any problem. But after adding default version, if we not add any ndkVersion in build.gradle then it search for the default version of ndk.
In my case, my gradle version was 3.6.3 and ndk installed 21.0.6113669 and i did not defined ndkVersion in my build.gradle. So, it search for default ndkVersion "20.0.5594570" according to my gradle version and gave me the same error. So, i simply add ndkVersion "21.0.6113669" in my build.gradle file and error gone.
In order to solve this problem, you must indicate to your IDE the version of your NDK in build.gradle. In this case, it should be version 21.0.6113669. For example:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.remed_mobile"
minSdkVersion 16
targetSdkVersion 28
ndkVersion '21.1.6352462'
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
If you do not indicate your version number, then the IDE takes a default version. If you've upgraded gradle, then it might not find the right version.
Add this line in build.gradle(app)
android {
ndkVersion "21.0.6113669"
}
This will solve the problem
https://github.com/gradle/gradle/issues/12440#issuecomment-606188282
This workes for me
edit local.properties file to add this
ndk.dir=/xxxxx/Android/sdk/ndk-bundle
Android Studio -> Preferences -> System settings -> Android SDK -> Got to SDK tools and remove NDK(Side by Side) and apply.
ndkVersion "21.0.6113669" /// <<---Add this in your android -> app -> build.gradle file.
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
ndkVersion "21.0.6113669"
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
I also got below error
No version of NDK matched the requested version 20.0.5594570. Versions available locally: 21.3.6113669
I just added my local NDK version to App level build.gradle file its solved.
android {
ndkVersion "My Available version here" (my case it 21.3.6113669)
}
flutter clean
flutter pub get
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
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.
Open your module's build.gradle file and edit :
android {
**ndkVersion** "version number of you NDK"
}
No version of NDK matched the requested version 20.0.5594570
Here I got solution
1====>first download NDK if you don't have
2====>Rename your NDK as your Project need (like here I need 20.0.5594570)
3====>After that in android folder open gradle.properties file
here you put your ndk location like this
then do react-native run-android... that's it
NDK issues resolved
thanks you!
If you have trouble finding an exact version of NDK you can download it from here, it was the case for me my IDE required version 21.1.6352462 while this version no longer exists on the official site (https://developer.android.com/ndk/downloads)
All Android NDK Native Development Kit by API,Version and OSes
go to your app's build.gradle file;
in android{ } add your ndk version available, this shows in your error info you post. In this case, your version is "21.0.6113669"
No version of NDK matched the requested version 20.0.5594570. Versions available locally: 21.0.6113669
android {
ndkVersion "21.0.6113669"
}
I found this problem in as fox or 4 In X.
In the root directory of OS, open and hide Gradle folder
add file gradle.properties
add code
ndk.dir=/Users/your os name/Library/Android/sdk/ndk
doen~
first install NDk from android studio and Tools>sdk manager>sdk tools than download ndk version and
than in your local.properties set ndk path
like this:
ndk.dir=/Users/{yourUserName}/Library/Android/sdk/ndk/21.4.7075529
I couldn't install the specified version (a weird error from android studio, it might be related to the Silicon chip), so I specified a newer version of ndk in my build.gradle and everything worked.
[My Error: requested ndk version 22.0.7026061 did not match the version 20.0.5594570 requested by ndk.dir]
MySolution: There seems to be different ndk versions pointing out in different places
Please find below details for the same: Please go to
Project Structure=> SDK Location=> NDK Location(make sure to check one proper ndk version)
2)Project Structure=>Modules=> under NDK Version(check the same version you have added in first step)
PFA image forStep2
3)Gotoyour Android studio project=> go to local.properties file=> check your ndk version number
If all 3 steps are proper with one current proper NDK version your error would have solved.
Note: make sure to sync the project files, clean project, rebuild the project.
Hope this would solve your problem!! Happy Coding:)
Hi I'm fairly new to android development. I have a question regarding the Gradle version and the distribution url in gradle-wrapper.properties
classpath "com.android.tools.build:gradle:$gradle_version"
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
So every once a while I need to update gradle version (because android studio requires it). How do I find the new version number. Sometimes I need to update the gradle wrapper too, so how do I find the new distributionUrl that works with new gradle version?
It feels no one talk about this part of the android development and there isn't good documentations especially after google io
The Gradle Wrapper version can be changed by executing ./gradlew wrapper --gradle-version=4.9 as described here. This will automatically update the distributionUrl in gradle-wrapper.properties. If you want to manually set the distributionUrl, you can rely on the URL conforming to the same pattern as in your example. In other words, you can simply change the part of the URL that specifies the version (4.4 in your example) to the desired version. Check the repository, you will see that all releases are available at URLs that conform to the pattern https://services.gradle.org/distributions/gradle-X.Y-DISTRIBUTIONTYPE.zip (with capitalization indicating variable parts). The list of releases are also available in more reader-friendly format on the "Releases" page of the Gradle Website.
I currently have build version 1 and the Google Play store wants me to update the build version before releasing the app.
In Gradle Scripts > build.gradle(Module:app) the versionCode is 1.
If I change it to 1.1 (say), the program wants to sync.
But when I sync, the build fails immediately with the starting message of:
"Could not find method versionCode() for arguments [1.1] on DefaultConfig_Decorated{name=main, dimension=null, minSdkVersion=DefaultA..." etc
If I go to Project Structure > Flavors , it's already updated to 1.1 so I don't see what else I need to change.
The version number in the manifest is not the version code in build.gradle, because by default it's 1.0, which corresponds to the default version number 1.0 (not version code 1) in build.gradle.
Any ideas?
I have also tried making the change direct from Project structure but result was the same.
Thanks
David
Version code is a Integer it should 1,2,3... so on
It will used by play store to update the APK
Version code always be incremental. Increment the version code in each release.
Version Name which is visual display where you can put like "1.0-Beta", "1.0.1" etc.
For more details checkout the below link
Android Version
Say I create a library and I added it as a dependency to my project gradle files.
I would like to know how and if it is possible to specify the version number on a/my server and have Gradle check the version number at build time & update the library if necessary without me having the explicitly update the version number in my gradle files.
So for example:
Say I have a whole bunch of apps which use my personal library currently at version 1. When I update my library to say version 2 I'd like, when I run build tasks for all my apps, to have Gradle check on some external location (say git repo) if the library version got updated.
If it has been updated i want gradle to automatically handle the updating of the version number and pulling in the correct version.
Quite simple, just grab the version from your server and dynamically add the version into your dependency's declaration.
def yourVersion = 'http://your-server/version.txt'.toURL().text
dependencies {
compile "your-company:your-lib:$yourVersion"
}
I've always added dependencies like this:
dependencies {
compile 'com.android.support:mediarouter-v7:19.+'
}
but in the recent versions of Android Studio, they recommend not to use the + as it can lead to errors. How to know what's the latest version? I can try every combination of 19.y.x until gradle complains, but what's the real way do check?
edit: sometimes, that page helps me figure it out.
There may be other ways, but here is what i use:
You can find out the latest version using Android Studio by replacing the version number of your library in build.gradle compile line, with just + , and click on Sync Now in upper right corner of the window.
in your case, for example
dependencies {
compile 'com.android.support:mediarouter-v7:+'
}
Android Studio will pop up a hint/bulb, which has options Replace with specific version you can click, which will fill-in the latest version in-place of +. Please see below screeshot:
If this doesn't work the first time, let gradle complete its sync, and retry (replace + with + or any file modification will do, click the sync now again and hint bulb will show up).
For example, for your library, i simply pasted this line compile 'com.android.support:mediarouter-v7:+' under my dependencies and followed the above process, Android Studio filled in with below version
Relying on latest version is indeed a dangerous thing to do. Your build can break without you changing anything, just because some library broke backwards compatibility.
The easiest way to know when new version of a library is out is to subscribe to new version notifications in Bintray.
Just click on the "Watch" button on the package page and you'll get an email every time new version is out. Then you'll be able to update the dependency, test it, and only then commit the build script with the new version.
As already mentioned by some other answers you should not use + in dependencies because it may lead to unpredictable builds, so its always better if you first test your builds once a new update is available.
With android studio 2.2 and above Project Structure will show you the latest dependencies available.
Activate it by going to Android Studio > Settings > Build,
Execution, Deployment > Gradle > Experimental and check the Use
new Project Structure dialog
Then open it by going to File >Project Structure > Messages
Original Answer
I use these two links.
This link gives me the latest buildTools Version
https://developer.android.com/studio/releases/build-tools.html
This link gives me the latest supportLibraryVersion
https://developer.android.com/topic/libraries/support-library/revisions.html
Recently, I have found this.
Go to File -> Project Structure
Select the Module, where you want to add the dependency.
Go to the Dependencies Tab
Click + and Choose Library Dependency
Choose whichever Library you need from the list.
(There is also an option for Search, never tried though.)
That's it.
Done.
Thank You.
Avoid to use + in version declare.
You can try andle to check if dependency out of date, also the build tool version and sdk version.
Simple three step:
1. install:
$ sudo pip install andle
2. set sdk:
$ andle setsdk -p <sdk_path>
3. update depedency:
$ andle update -p <project_path> [--dryrun] [--remote]
--dryrun: only print result in console
--remote: check version in jcenter and mavenCentral
the answer of ashoke is correct if you want the latest version.
But if you just want to replace "+" by the version you are currently using (therefor protection yourself against bug in future update)
eg:
compile 'com.android.support:appcompat-v7:21.0.+'
to
compile 'com.android.support:appcompat-v7:21.0.3'
(but not using 23.0.1)
this is the easiest way, no software needed:
run
$ ./gradlew clean tasks --debug > ~/whatever.txt
then look for "com.android.support:appcompat-v7:21.0."
a few line below you will see
"Using com.android.support:appcompat-v7:21.0.3 from Maven repository"
If it is a dependency that comes from Google's maven repository, the best way these days is to go to https://maven.google.com , where google now lets you browse all their libraries and see all the versions available, including the latest version. It looks like this:
You can even do a search for a specific library, and then expand/collapse it as desired: