Visitar URL original
Preprovision Android NDK before flavored builds by kyungilcho · Pull Request #183512 · flutter/flutter · GitHub
Skip to content

Preprovision Android NDK before flavored builds - #183512

Closed
kyungilcho wants to merge 13 commits into
flutter:masterfrom
kyungilcho:fix/android-cross-flavor-ndk-build
Closed

kyungilcho wants to merge 13 commits into
flutter:masterfrom
kyungilcho:fix/android-cross-flavor-ndk-build

Conversation

@kyungilcho

Copy link
Copy Markdown
Contributor

Flutter currently forces AGP to download the NDK by configuring an empty CMake project in forceNdkDownload().

In flavored Android apps, that synthetic native configuration can cause AGP to fold generic CMake tasks across flavors, which can pull compileFlutterBuild tasks from the wrong flavor into the active build.

This change moves NDK provisioning into the Flutter tool build flow:

  • query the effective ndkVersion with a lightweight Gradle metadata task
  • install the required NDK before the main build when needed
  • skip forceNdkDownload() when the tool has already preprovisioned the NDK

This preserves the original goal of ensuring the NDK is available, while avoiding synthetic native build graph contamination in flavored apps.

Manual validation:

  • flavored minimal Android app: debug and release
  • real app: flutter build apk --debug --flavor dev
  • real app: flutter build apk --flavor dev
  • real app: flutter build appbundle --flavor dev
  • real app: flutter run --flavor dev

Tests:

  • packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart
  • packages/flutter_tools/test/integration.shard/android_run_flutter_gradle_plugin_tests_test.dart
  • packages/flutter_tools/test/integration.shard/android_gradle_print_ndk_version_test.dart

Refs #183296

@github-actions github-actions Bot added a: tests "flutter test", flutter_test, or one of our tests platform-android Android applications specifically platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels. framework flutter/packages/flutter repository. See also f: labels. engine flutter/engine related. See also e: labels. p: material_ui material_ui package in flutter/packages a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) p: cupertino_ui cupertino_ui package in flutter/packages platform-web Web applications specifically a: desktop Running on desktop e: impeller Impeller rendering backend issues and features requests team-android Owned by Android platform team team-ios Owned by iOS platform team team-macos Owned by the macOS platform team platform-macos labels Mar 11, 2026
@kyungilcho
kyungilcho changed the base branch from main to master March 11, 2026 13:30
@kyungilcho
kyungilcho force-pushed the fix/android-cross-flavor-ndk-build branch from bdcc6c8 to 0caaf03 Compare March 11, 2026 13:34
@github-actions github-actions Bot removed a: tests "flutter test", flutter_test, or one of our tests platform-ios iOS applications specifically framework flutter/packages/flutter repository. See also f: labels. engine flutter/engine related. See also e: labels. p: material_ui material_ui package in flutter/packages a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) p: cupertino_ui cupertino_ui package in flutter/packages platform-web Web applications specifically a: desktop Running on desktop labels Mar 11, 2026
@github-actions github-actions Bot removed e: impeller Impeller rendering backend issues and features requests team-ios Owned by iOS platform team team-macos Owned by the macOS platform team platform-macos labels Mar 11, 2026
@kyungilcho
kyungilcho force-pushed the fix/android-cross-flavor-ndk-build branch from 6e2d007 to a97e76c Compare March 11, 2026 14:32
@fluttergithubbot

Copy link
Copy Markdown
Contributor

An existing Git SHA, a97e76cd4db3c52a65063d3aa2a9056a400ef075, was detected, and no actions were taken.

To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with --force) that already was pushed before, push a blank commit (git commit --allow-empty -m "Trigger Build") or rebase to continue.

@kyungilcho kyungilcho closed this Mar 12, 2026
@kyungilcho

Copy link
Copy Markdown
Contributor Author

Closing this in favor of #183555, which rebuilds the change on top of the latest master with a clean two-commit history.

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.

2 participants