-
Notifications
You must be signed in to change notification settings - Fork 29.1k
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
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.