Skip to content

[flutter_tools] Provision Android NDK in the main Gradle invocation#186337

Draft
kyungilcho wants to merge 5 commits into
flutter:masterfrom
kyungilcho:draft/android-ndk-single-invocation
Draft

[flutter_tools] Provision Android NDK in the main Gradle invocation#186337
kyungilcho wants to merge 5 commits into
flutter:masterfrom
kyungilcho:draft/android-ndk-single-invocation

Conversation

@kyungilcho
Copy link
Copy Markdown
Contributor

Summary

  • move Android NDK provisioning into the main Gradle invocation
  • pass the sdkmanager path, Android SDK root, and validated installed NDK versions from flutter_tools to the Flutter Gradle Plugin
  • only fall back to the synthetic externalNativeBuild/CMake path when the main invocation cannot satisfy provisioning

Context

This is a draft to explore the single-invocation direction discussed after #183555 and #185439.

The goal here is to keep the cleaner shape of doing the NDK check where AGP has already resolved the actual ndkVersion, while also tightening the behavior around installation and fallback.

Design

  • AndroidGradleBuilder now receives AndroidSdk explicitly instead of reading it from globals
  • flutter_tools passes:
    • flutter.androidSdkRoot
    • flutter.installedNdkVersions
    • flutter.sdkManagerPath when installation is actually possible
  • the plugin now:
    • returns early when the resolved NDK is already installed
    • installs the resolved NDK with sdkmanager --sdk_root=... when possible
    • verifies source.properties after installation
    • falls back to the synthetic CMake path only when the tool-provided path cannot handle the build

Validation

  • packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart
  • packages/flutter_tools/gradle: FlutterPluginUtilsTest
  • local benchmarking still shows the same structural improvement as the earlier prototype:
    • no extra printNdkVersion Gradle invocation
    • no unexpected .cxx output in the fast path

Notes

This is still a draft because I want feedback on the shape before turning it into the replacement for the narrower flavored-only reland.

@github-actions github-actions Bot added platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels. team-android Owned by Android platform team labels May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform-android Android applications specifically team-android Owned by Android platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant