Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Hey @StasDoskalenko 👋 |
|
Hey @V3RON, sure, will do 👍 |
|
Tested this on a real Windows machine (Windows 11, JDK 21, Android SDK installed the normal way through Android Studio). Good news and a new finding. What's fixedI ran the built
That's exactly what #191 and #183 describe, and it's fixed. What's still brokenOnce past that check, harness tries to install missing SDK packages through Repro with It isn't specific to that one argument. Calling import nanoSpawn from 'nano-spawn';
await nanoSpawn('C:\\...\\Sdk\\cmdline-tools\\latest\\bin\\avdmanager.bat', ['list', 'avd']);
// exit 255: "The syntax of the command is incorrect."WhySince a Node security fix (CVE-2024-27980), That hand escaping does not survive Android's own I checked whether this is just a stale Practically, this means the two things #191 calls out explicitly, accepting SDK licenses / installing packages, and SuggestionI don't think this is fixable by adjusting how the arguments are built (I tried both a combined Update: tried the java-direct fix locally, it worksWent ahead and prototyped this locally (not pushed anywhere, happy to open it as a real PR against your branch if you want it that way instead). Both On win32, instead of spawning the Validated end to end on the same machine, cold SDK state each time:
One more thing I ran into and worked around: the new Rough diff of the approach ( // environment.ts
const getJavaBinaryPath = (): string => {
const javaHome = process.env.JAVA_HOME;
const exeName = process.platform === 'win32' ? 'java.exe' : 'java';
return javaHome ? path.join(javaHome, 'bin', exeName) : exeName;
};
const getCmdlineToolsDir = (sdkRoot: string): string =>
path.join(sdkRoot, ...CMDLINE_TOOLS_PATH_SEGMENTS);
const runAvdManagerWindows = (sdkRoot, args, spawnOptions) => {
const classpath = path.join(getCmdlineToolsDir(sdkRoot), 'lib', 'avdmanager-classpath.jar');
return spawn(
getJavaBinaryPath(),
[
'-Dcom.android.sdkmanager.toolsdir=' + getCmdlineToolsDir(sdkRoot),
'-classpath', classpath,
'com.android.sdklib.tool.AvdManagerCli',
...args,
],
spawnOptions,
);
};
export const runAvdManager = (args, spawnOptions, sdkRoot = getRequiredAndroidSdkRoot()) =>
process.platform === 'win32'
? runAvdManagerWindows(sdkRoot, args, spawnOptions)
: spawn(getAvdManagerBinaryPath(sdkRoot), args, spawnOptions);
// sdkmanager: same idea, falls back to the classic `sdkmanager-classpath.jar`
// + `com.android.sdklib.tool.sdkmanager.SdkManagerCli` when present, otherwise
// calls `android.exe --sdk=<root> sdk install <packages>` directly.I know this is a fair bit more surface area than the current PR, so entirely your call whether you want it folded in here, as a follow-up, or done differently. Let me know if you want the actual patch. |
What is this?
Harness can now run the Android platform from a Windows host. Previously it failed before reaching a device, reporting "Android command-line tools are missing" even with a correctly installed SDK. The Android package assumed POSIX file names, used
bashpipelines, and built paths from$HOME.Fixes #191, fixes #183.
How does it work?
Harness already runs every command through
nano-spawn, which resolvesPATHEXTand runs.batfiles throughcmd.exe. That means Windows needs only one check, in the SDK binary path helpers:win32,adbandemulatorresolve to.exe, andsdkmanagerandavdmanagerresolve to.bat. Existence checks now look for the real files.ANDROID_HOMEnorANDROID_SDK_ROOTis set, the default SDK location on Windows is%LOCALAPPDATA%\Android\Sdk.The rest of the change removes POSIX-only code rather than adding branches for Windows:
yes | sdkmanager …andprintf 'no\n' | avdmanager …now start the tool directly and write the answers to its stdin. This also removes the hand-rolled shell quoting..inifile and theconfig.iniadditions are written withfs.writeFile/fs.appendFileinstead ofprintfredirection.path.join(os.homedir(), '.android', 'avd')behind one shared helper instead of${process.env.HOME}/….Automatically downloading the command-line tools on Windows is still unsupported and keeps its existing "set ANDROID_HOME" error.
Why is this useful?
Teams developing on Windows can run Harness Android tests locally against physical devices and emulators. On macOS and Linux, SDK and AVD management no longer depends on
bashbeing available.