Skip to content

Android platform fails on Windows hosts #191

Description

@V3RON

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions