)]}'
{
  "commit": "36b4b8f8e431ff27cdc747b2f0cbd142695d77ce",
  "tree": "f3cc0b567c62f1359fb7b5f9badb4c6fe183891b",
  "parents": [
    "3a8e191c9eaf0015544c998220edd9d5668fe662"
  ],
  "author": {
    "name": "Ben Konyi",
    "email": "bkonyi@google.com",
    "time": "Tue Sep 29 19:56:28 2026 +0000"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Tue Sep 29 19:56:28 2026 +0000"
  },
  "message": "[flutter_tools] Lazily initialize AndroidSdk platform and build-tools discovery (#191972)\n\n## Description\n\nThis PR optimizes `AndroidSdk` initialization by deferring expensive\nsynchronous filesystem operations out of the constructor.\n\n### Why this is needed now\nAs part of the modular dependency injection migration\n([#190724](https://github.com/flutter/flutter/pull/190724)), context\nobjects like `AndroidContext` are created upfront during\n`ToolDependencies.bootstrap` / runner initialization rather than via the\nold global ambient context (`AppContext`).\n\nPreviously, `AndroidSdk` was initialized lazily only when a command or\nservice queried `globals.androidSdk` or `context.get\u003cAndroidSdk\u003e()`.\nWith upfront `AndroidContext` creation, `AndroidSdk.locateAndroidSdk()`\nruns on tool startup for every command. Because the `AndroidSdk`\nconstructor eagerly executed `reinitialize()`, it performed synchronous\ndirectory listings across `build-tools` and `platforms` directories and\nread `build.prop` files on disk. This introduced unnecessary disk I/O\nand latency to tool startup, including for commands completely unrelated\nto Android (such as `flutter config` or iOS-specific workflows).\n\n### Changes\n- Defers synchronous scanning of build-tools and platform directories\n(`reinitialize()`) out of the `AndroidSdk` constructor so that object\ninstantiation is fast and side-effect free.\n- `sdkVersions` and `latestVersion` are evaluated lazily on first\naccess.\n- Retains `_fileSystem` on the instance so that explicit calls to\n`reinitialize()` continue to refresh platform and version state with the\nexpected filesystem.\n\n## Related Issues\nPart of [#47161](https://github.com/flutter/flutter/issues/47161)\n(flutter_tools modular dependency injection migration).\n\n## Tests\n- Updated existing test in\n`packages/flutter_tools/test/general.shard/android/android_sdk_test.dart`\n(`constructing an AndroidSdk handles no matching lines in build.prop`)\nto access `sdk.latestVersion` so that `build.prop` parsing\nerror-handling is executed during lazy initialization.\n- Added unit tests verifying:\n- Constructor instantiation does not initialize `sdkVersions` or\n`latestVersion` or scan platform directories.\n- `sdkVersions` and `latestVersion` evaluate lazily on first access\nacross independent instances.\n- Calling `reinitialize()` updates `sdkVersions` and `latestVersion` and\ncorrectly falls back to stored `_fileSystem`.",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "c89a69532157a4b6d41b6923831ae13ce36db483",
      "old_mode": 33188,
      "old_path": "packages/flutter_tools/lib/src/android/android_sdk.dart",
      "new_id": "ab72c1ea6daab61a62258a426e4651e91c7bc423",
      "new_mode": 33188,
      "new_path": "packages/flutter_tools/lib/src/android/android_sdk.dart"
    },
    {
      "type": "modify",
      "old_id": "42e9c94cd2dbbad38a44f78447ba6b89345ab39f",
      "old_mode": 33188,
      "old_path": "packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart",
      "new_id": "f3dc2a97b9d635f0f2cb119e50602f22bfab3a8a",
      "new_mode": 33188,
      "new_path": "packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart"
    },
    {
      "type": "modify",
      "old_id": "01f8df93518eed6b4408f4581d4cfe30f6856f0b",
      "old_mode": 33188,
      "old_path": "packages/flutter_tools/test/general.shard/android/android_sdk_test.dart",
      "new_id": "01dfece3811be0cc67e72d797dbdfaf857cf5bf5",
      "new_mode": 33188,
      "new_path": "packages/flutter_tools/test/general.shard/android/android_sdk_test.dart"
    },
    {
      "type": "modify",
      "old_id": "d1f7196fa54ee972aeed5a45925a9f94edec547c",
      "old_mode": 33188,
      "old_path": "packages/flutter_tools/test/general.shard/cache_test.dart",
      "new_id": "10e79a45aff7740acc76c61415957b161bf9472c",
      "new_mode": 33188,
      "new_path": "packages/flutter_tools/test/general.shard/cache_test.dart"
    }
  ]
}
