Hi everyone,I’m trying to build my Flutter app for Android, but I’m running into the following error:
text
Apply to main.dart
Build file ‘E:\devE\js\nsang19\flutter\fl2\android\build.gradle.kts’ line: 16
A problem occurred configuring project ‘:app’.
NDK not configured. Download it with SDK manager. Preferred NDK version is ‘27.0.12077973’.
I have downloaded a ndk , android studio doesn’t give me the option to download that specific one tho.
Any help would be appreciated! Thanks in advance.
I think there’s a line in the error that tells you to define the version in your build.gradle file
I don’t know why this is still happening
opened 07:08PM - 02 Dec 23 UTC
platform-android
tool
t: gradle
customer: crowd
c: proposal
P3
team-android
triaged-android
### Is there an existing issue for this?
- [X] I have searched the [existing … issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)
### Use case
Right now Flutter Android tools specify min SDK, compile SDK and so on, which is Ok. However, it also specifies the NDK: https://github.com/flutter/flutter/blob/3.16.2/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy#L62 and pins it to the version of AGP used by Flutter. This isn't necessary as AGP already comes with the default versions they test against and recommend, see https://developer.android.com/studio/projects/install-ndk#default-ndk-per-agp (which is also mentioned in the comment over the line I linked to).
This is a bit problematic when people use a different (newer) AGP version, for whatever reason. In that case, this is what I see with Flutter 3.16.2 (latest stable as of writing this) when I build my app:
```
One or more plugins require a higher Android NDK version.
Fix this issue by adding the following to /Users/wujek/Development/myflutterapp/android/app/build.gradle:
android {
ndkVersion "25.1.8937393"
...
}
```
The solution for me is to simply comment out the line `ndkVersion flutter.ndkVersion`.
### Proposal
I propose that Flutter not manage the NDK version in its internals, and instead lets it be picked up from the AGP version used by the project. If the developer sticks with the AGP version that Flutter defined when the project was generated, it will be the exact same one as the one that Flutter specifies in https://github.com/flutter/flutter/blob/3.16.2/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy#L62. If the developer decides to update their AGP to a newer version, there will be no NDK-related warning because the correct one will be picked up as well.
This is reminiscent of another bug that I filed some time ago (#101373), where Flutter was unnecessarily specifying a Kotlin version, whereas it was already specified by default by the applied Gradle Kotlin plugin. I believe that, similar the Kotlin-version-bug, the solution that will work best is to remove stuff.
I think it’s this and it’s still open
Update your gradle file with:
android {
ndkVersion = “27.0.12077973”
// … other config
}
save and in terminal (I use vs code so i do not know much about AS.
Do flutter clean && flutter pub get
Hope this helps