Describe the bug
The Android platform doesn't work when Harness runs on a Windows host. The first failure, reported in #183, is:
Android command-line tools are missing. Set ANDROID_HOME or ANDROID_SDK_ROOT to an initialized SDK.
It happens even when the SDK is installed correctly. @react-native-harness/platform-android assumes a POSIX host in several places:
- Binary paths have no extension. Harness checks for
platform-tools/adb, emulator/emulator, cmdline-tools/latest/bin/sdkmanager and bin/avdmanager. On Windows these files are adb.exe, emulator.exe, sdkmanager.bat and avdmanager.bat, so the existence checks fail.
- Some steps shell out to
bash -lc. Accepting SDK licenses and installing packages (yes | sdkmanager …), creating an AVD (printf 'no\n' | avdmanager …), and writing AVD .ini files (printf … > file) all do this. Windows has no bash.
- AVD paths use
$HOME. The fallback when ANDROID_AVD_HOME isn't set is ${process.env.HOME}/.android/avd. HOME usually isn't set on Windows.
- There's no default SDK root on Windows. Harness only knows the macOS and Linux default locations, not
%LOCALAPPDATA%\Android\Sdk.
Harness runs commands through nano-spawn, which already resolves PATHEXT and runs .bat/.cmd files through cmd.exe. So this can be fixed with platform-neutral code plus a single Windows check in the binary path helpers, without adding platform conditionals throughout the package.
Expected behavior
Harness finds an Android SDK installed on Windows and can run tests on physical devices and existing or newly created emulators.
Out of scope
Automatically downloading the Android command-line tools on Windows. That keeps failing with a clear "set ANDROID_HOME" error.
React Native Harness Version
1.4.1 and later
Steps to reproduce
On Windows, with an Android SDK installed and ANDROID_HOME set, run react-native-harness --harnessRunner android against a connected device.
Describe the bug
The Android platform doesn't work when Harness runs on a Windows host. The first failure, reported in #183, is:
It happens even when the SDK is installed correctly.
@react-native-harness/platform-androidassumes a POSIX host in several places:platform-tools/adb,emulator/emulator,cmdline-tools/latest/bin/sdkmanagerandbin/avdmanager. On Windows these files areadb.exe,emulator.exe,sdkmanager.batandavdmanager.bat, so the existence checks fail.bash -lc. Accepting SDK licenses and installing packages (yes | sdkmanager …), creating an AVD (printf 'no\n' | avdmanager …), and writing AVD.inifiles (printf … > file) all do this. Windows has nobash.$HOME. The fallback whenANDROID_AVD_HOMEisn't set is${process.env.HOME}/.android/avd.HOMEusually isn't set on Windows.%LOCALAPPDATA%\Android\Sdk.Harness runs commands through
nano-spawn, which already resolvesPATHEXTand runs.bat/.cmdfiles throughcmd.exe. So this can be fixed with platform-neutral code plus a single Windows check in the binary path helpers, without adding platform conditionals throughout the package.Expected behavior
Harness finds an Android SDK installed on Windows and can run tests on physical devices and existing or newly created emulators.
Out of scope
Automatically downloading the Android command-line tools on Windows. That keeps failing with a clear "set ANDROID_HOME" error.
React Native Harness Version
1.4.1 and later
Steps to reproduce
On Windows, with an Android SDK installed and
ANDROID_HOMEset, runreact-native-harness --harnessRunner androidagainst a connected device.