Skip to content

[flutter_tools] Introduce AndroidSdkProvider for lazy native_assets SDK lookup - #196122

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
bkonyi:di/native-assets-android-sdk-provider
Nov 11, 2026
Merged

auto-submit[bot] merged 2 commits into
flutter:masterfrom
bkonyi:di/native-assets-android-sdk-provider

Conversation

@bkonyi

@bkonyi bkonyi commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Introduces the AndroidSdkProvider interface implemented by AndroidContext and Environment so native_assets can defer AndroidSdk lookup until C compiler configuration is needed without passing raw builder callbacks.

Also explicitly injects FeatureFlags and VisualStudio into native_assets hook runners and build targets instead of reading from ambient globals.

Part of #47161

…DK lookup

Introduces the `AndroidSdkProvider` interface implemented by `AndroidContext` and `Environment` so `native_assets` can defer `AndroidSdk` lookup until C compiler configuration is needed without passing raw builder callbacks.

Also explicitly injects `FeatureFlags` and `VisualStudio` into `native_assets` hook runners and build targets instead of reading from ambient globals.

Part of flutter#47161
@bkonyi bkonyi added tool Affects the "flutter" command-line tool. See also t: labels. CICD Run CI/CD labels Nov 6, 2026
@github-actions github-actions Bot added a: desktop Running on desktop team-android Owned by Android platform team team-ios Owned by iOS platform team team-macos Owned by the macOS platform team team-windows Owned by the Windows platform team team-linux Owned by the Linux platform team labels Nov 6, 2026
@bkonyi
bkonyi requested a review from chingjun November 9, 2026 19:30
@bkonyi
bkonyi marked this pull request as ready for review November 9, 2026 19:30
@bkonyi
bkonyi requested review from a team as code owners November 9, 2026 19:30
@bkonyi
bkonyi requested review from mboetger and removed request for a team November 9, 2026 19:30

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors native assets build targets to lazily resolve the Android SDK by introducing the AndroidSdkProvider interface, which is implemented by both AndroidContext and Environment. This change prevents unnecessary Android SDK lookups during data-only build hook executions. The review feedback points out a compile-time error in AndroidAssetTarget where the constructor defines a private named parameter _androidSdkProvider but the call site passes androidSdkProvider. It is recommended to make this parameter and field public.

/// The returned dependencies only include those collected during the link stage.
/// The returned assets only include those produced during the link stage.
Future<DartHooksResult> runFlutterSpecificLinkHooks({
required AndroidSdkProvider? androidSdkProvider,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be non nullable?

/// lookup until an Android toolchain is needed.
abstract interface class AndroidSdkProvider {
/// The configured [AndroidSdk], or `null` if no Android SDK is available.
AndroidSdk? get androidSdk;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it would be better to make this non nullable?

required ProcessUtils processUtils,
bool mustMatchAppBuild = true,
}) async => cCompilerConfigSync = await cCompilerConfigAndroid(androidSdk: androidSdk);
}) async => cCompilerConfigSync = await cCompilerConfigAndroid(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly out of scope of this PR, cCompilerConfigAndroid will not accept a null value in runtime anyway, would it be cleaner if we make that nonnull and try to make as many AndroidSdkProvider? to be nonnull in this CL?

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 11, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 11, 2026
Merged via the queue into flutter:master with commit 1c669cb Nov 11, 2026
21 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 11, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 12, 2026
flutter/flutter@b98afb5...9c427b5

2026-11-12 [email protected] Roll Skia from d67d0f22e3ec to 9aa2513a4ac9 (2 revisions) (flutter/flutter#196429)
2026-11-12 [email protected] [flutter_tools] Move CpuArch to flutter_tools_core and define HostPlatform by osName and cpuArch (flutter/flutter#195841)
2026-11-12 [email protected] Roll Skia from 23e7e63789b8 to d67d0f22e3ec (2 revisions) (flutter/flutter#196424)
2026-11-12 [email protected] Uber compactify (flutter/flutter#196392)
2026-11-12 [email protected] Roll Skia from 3d7e335da165 to 23e7e63789b8 (12 revisions) (flutter/flutter#196422)
2026-11-12 [email protected] Roll Dart SDK from 13af329ea4f2 to e5add7a25b32 (1 revision) (flutter/flutter#196413)
2026-11-12 [email protected] Don't terminate the shared EGL display when an engine is disposed (flutter/flutter#194520)
2026-11-11 [email protected] Adds manifest flag to turn on SDFs for Android. (flutter/flutter#196056)
2026-11-11 [email protected] Remove bringup from Linux_pixel_7pro integration_ui_keyboard_inset_jump (flutter/flutter#196334)
2026-11-11 [email protected] Uses system default locale for text rendering when preferred locale isn't supported (flutter/flutter#195997)
2026-11-11 [email protected] [android]: prewarms shaders when the context is created (flutter/flutter#196069)
2026-11-11 [email protected] iOS: Recomposite platform views only if their parameters change (flutter/flutter#196287)
2026-11-11 [email protected] [flutter_tools] Forward encoding in ErrorHandlingFile.readAsStringSync (flutter/flutter#196136)
2026-11-11 [email protected] Roll Skia from b89c24bbab8c to 3d7e335da165 (8 revisions) (flutter/flutter#196390)
2026-11-11 [email protected] Add Flutter Gardener instructions on how to disable a test (flutter/flutter#196312)
2026-11-11 [email protected] [Impeller] Enable malioc analysis for framebuffer_blend shaders (flutter/flutter#196343)
2026-11-11 [email protected] [flutter_tools] Migrate general.shard Android, asset, and build tests off globals (flutter/flutter#196125)
2026-11-11 [email protected] Roll Dart SDK from 8f15c4ca2d41 to 13af329ea4f2 (1 revision) (flutter/flutter#196386)
2026-11-11 [email protected] [Impeller] Do not clamp the local coverage limit to the root render target (flutter/flutter#195860)
2026-11-11 [email protected] [Impeller] Use separate uniform buffers on VMware SVGA3D (flutter/flutter#196022)
2026-11-11 [email protected] [flutter_tools] Introduce AndroidSdkProvider for lazy native_assets SDK lookup (flutter/flutter#196122)
2026-11-11 [email protected] Moves linux to ThinLTO. (flutter/flutter#196314)
2026-11-11 [email protected] [flutter_tools] Migrate bin/fuchsia_tester.dart off globals and runInContext (flutter/flutter#196074)
2026-11-11 [email protected] Changes the tolerances for frame_rate_main_test.dart. (flutter/flutter#196304)
2026-11-11 [email protected] Roll Packages from 08faf64 to 653628e (16 revisions) (flutter/flutter#196381)
2026-11-11 [email protected] Allow SliverCrossAxisGroup children to lay out with zero cross-axis extent instead of asserting (flutter/flutter#191287)
2026-11-11 [email protected] Roll Skia from cc4c54f752ba to b89c24bbab8c (4 revisions) (flutter/flutter#196375)
2026-11-11 [email protected] [Linux] Fix layer offset when compositing with glBlitFramebuffer (flutter/flutter#196189)
2026-11-11 [email protected] [flutter_tools] Inject CrashReportSender into SwiftPM migration (flutter/flutter#196315)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop CICD Run CI/CD team-android Owned by Android platform team team-ios Owned by iOS platform team team-linux Owned by the Linux platform team team-macos Owned by the macOS platform team team-windows Owned by the Windows 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