19

My flutter app could build fine before, but after updating Android Studio and Flutter today I get the following error when trying to build: "No version of NDK matched the requested version 20.0.5594570. Versions available locally: 21.0.6113669". How can this error be solved?

ClWin
  • 346
  • 1
  • 2
  • 11
  • It seems to be Android studio problem, please try to run `flutter run` command from terminal and check that app is running or not to check issue is in Android studio side or flutter side. – Devarsh Ranpara Feb 25 '20 at 12:22
  • this is the same as: https://stackoverflow.com/questions/61157024/compatible-side-by-side-ndk-version-was-not-found-default-is-20-0-5594570/61510602#61510602 – Gerry Apr 29 '20 at 20:02

4 Answers4

16

The NDK version 20.0.5594570 can be install manually by going into android studio -> SDK manager -> SDK tools. Select the show package detail checkbox.

You will be able to see all the NDK versions available.

More details: https://developer.android.com/studio/projects/install-ndk

mingliang94
  • 234
  • 2
  • 7
6

If this issue occurred after updating android studio to 3.6 or updating the gradle plugin or gradle wrapper, then 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

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

It's usually recommended to install the latest version fo NDK available and use that for your projects.

Community
  • 1
  • 1
Subaru Tashiro
  • 2,166
  • 1
  • 14
  • 29
  • 1
    A small problem. AS 3.6 from February 2020 has a rather different Project Structure dialog, without the item you mention. *Check for updates* says this is the latest one. – Gábor Feb 26 '20 at 09:21
  • @Gábor The screenshot I included in my answer is the recent AS 3.6 - the info from the 'about' screen shows the following info. Android Studio 3.6 Build #AI-192.7142.36.36.6200805, built on February 12, 2020 Runtime version: 1.8.0_212-release-1586-b04 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0 – Subaru Tashiro Feb 26 '20 at 11:44
  • Partly yes, partly no, as I found out right now. It depends on the project type. The dialog you showed appears for an Android project but not for a Flutter one for me. With a Flutter app, the accepted answer was the one that helped me, too: installing the required NDK. – Gábor Feb 26 '20 at 13:21
  • @Gábor if you don't mind investigating, does the other answers in the ff link apply for flutter projects? https://stackoverflow.com/a/60413117/1099775 – Subaru Tashiro Feb 27 '20 at 05:49
  • I think this is the correct answer for the general use of the NDK. – Jan Bergström Mar 02 '20 at 00:35
  • "For Flutter apps, First you have to open the android path as a project." See @AyTee answer's above. – TechAurelian Jun 06 '20 at 07:17
5

For Flutter apps, First you have to open the android path as a project. You can do it by opening some file for editing under the "android" folder end then click "Open for Editing in Android Studio" on top.

Then you can do as @Subaru suggests:

You can open the Project Structure Dialog by clicking File > Project Structure... or by pressing the hotkeys CTRL + ALT + SHIFT + S

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.

AyTee
  • 489
  • 1
  • 8
  • 19
3

You can update in your local.properties the property which point to the ndk location : ndk.dir=/Users/Shared/develop/android-sdk/ndk-bundle

danysz
  • 580
  • 3
  • 11