Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Android runner can't start on a Windows host: SDK binaries are looked up without .exe or .bat

已关闭 适合新手
#201 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
android, nodejs, react-native, typescript
领域
mobile-dev

调研方向

从 packages/platform-android/src/environment.ts 开始,这里的 getAdbBinaryPath、getEmulatorBinaryPath、getSdkManagerBinaryPath 和 getAvdManagerBinaryPath 在构建 SDK 路径时没有加上 Windows 扩展名。检查 ensureAndroidAdbAvailable 和 ensureAndroidCommandLineTools 如何使用这些路径,以及在哪里启动 .bat 文件,在 win32 上这需要 shell: true。完成的标准是:在 Windows 上查找能解析出 adb.exe、emulator.exe、sdkmanager.bat 和 avdmanager.bat,并且 Android 运行器在 Windows 主机上通过 SDK 检查。

由索引模型根据 Issue 内容生成。

描述

Describe the bug

On Windows, every Android runner — emulator or physical device — fails before it reaches a device, with:

Error: Android command-line tools are missing. Set ANDROID_HOME or ANDROID_SDK_ROOT to an initialized SDK.
    at ensureAndroidCommandLineTools (packages/platform-android/dist/environment.js:114:15)
    at async ensureAndroidSdkPackages (packages/platform-android/dist/environment.js:252:5)
    at async Module.getAndroidRunner (packages/platform-android/dist/runner.js:7:5)
    at async Object.work (packages/jest/dist/harness-session.js:411:32)
    at async withPlatformReadyTimeout (packages/jest/dist/harness-session.js:99:16)
    at async Promise.all (index 1)

although ANDROID_HOME points at an SDK with platform-tools and cmdline-tools installed. (What a user actually sees is an AbortError crash; the message above shows once that is fixed: #200.)

packages/platform-android/src/environment.ts builds the SDK paths without Windows extensions: getAdbBinaryPath gives platform-tools/adb, getEmulatorBinaryPath emulator/emulator, and getSdkManagerBinaryPath / getAvdManagerBinaryPath cmdline-tools/latest/bin/sdkmanager / avdmanager, where Windows has adb.exe, emulator.exe, sdkmanager.bat and avdmanager.bat. So ensureAndroidAdbAvailable decides platform-tools is missing, the bootstrap then finds no sdkmanager, and throws. With adb.exe alone, a runner on an already running emulator works — I ran #197's reproduction that way. Appending the extension on win32 fixes the lookups; spawning a .bat also needs shell: true there, since Node's fix for CVE-2024-27980.

System Info
System:
  OS: Windows 11 10.0.26200
Binaries:
  Node: 26.5.0
SDKs:
  Android SDK:
    API Levels: 35, 36, 37
    Build Tools: 35.0.0, 36.0.0, 36.1.0, 37.0.0
react-native: 0.82.1 (apps/playground)
React Native Harness Version

1.5.0 (main at 58850ce)

Reproduction

https://github.com/callstackincubator/react-native-harness/tree/main/apps/playground

Steps to reproduce
  1. On Windows, with ANDROID_HOME set to an Android SDK that has platform-tools and cmdline-tools, build the playground for Android.
  2. Run react-native-harness --harnessRunner android in apps/playground.
  3. It exits before reaching the emulator.
主要语言
TypeScript
星标
333
派生
20
平均合并
14 小时 55 分钟
30 天内合并 PR
44

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

callstackincubator/react-native-harness 的其他 Issue

查看 callstackincubator/react-native-harness 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。