Skip to content

Use the default NDK version from AGP #139427

@wujek-srujek

Description

@wujek-srujek

Is there an existing issue for this?

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: proposalA detailed proposal for a change to Fluttercustomer: crowdAffects or could affect many people, though not necessarily a specific customer.platform-androidAndroid applications specificallyt: gradle"flutter build" and "flutter run" on Androidteam-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions