From 9f8c1250d6f461808b24ea195a7b77abb1bc2f06 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 9 Mar 2026 12:09:16 +0000 Subject: [PATCH] Fix Android arm64 support by falling back to Linux arm64 GNU binary On Android, process.platform returns 'android' instead of 'linux', so the NAPI-RS generated loader looks for android-specific binaries that don't exist. Since Android is Linux under the hood, the Linux arm64 GNU binary works fine. Changes: - index.js: Add fallback to linux-arm64-gnu binary in the Android arm64 path - npm/linux-arm64-gnu/package.json: Add 'android' to os array so npm installs the linux-arm64-gnu package on Android devices https://claude.ai/code/session_015zso6wY1hJMst67LiXp4LW --- index.js | 17 +++++++++++++++++ npm/linux-arm64-gnu/package.json | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 3cf0e16..de8097b 100644 --- a/index.js +++ b/index.js @@ -69,6 +69,7 @@ function requireNative() { } } else if (process.platform === 'android') { if (process.arch === 'arm64') { + // Try Android-specific binaries first try { return require('./hypersync-client.android-arm64.node') } catch (e) { @@ -84,6 +85,22 @@ function requireNative() { } catch (e) { loadErrors.push(e) } + // Fall back to Linux arm64 GNU binary (Android is Linux under the hood) + try { + return require('./hypersync-client.linux-arm64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@envio-dev/hypersync-client-linux-arm64-gnu') + const bindingPackageVersion = require('@envio-dev/hypersync-client-linux-arm64-gnu/package.json').version + if (bindingPackageVersion !== '1.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 1.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } } else if (process.arch === 'arm') { try { return require('./hypersync-client.android-arm-eabi.node') diff --git a/npm/linux-arm64-gnu/package.json b/npm/linux-arm64-gnu/package.json index a63d565..810cd99 100644 --- a/npm/linux-arm64-gnu/package.json +++ b/npm/linux-arm64-gnu/package.json @@ -14,7 +14,8 @@ "node": ">= 10" }, "os": [ - "linux" + "linux", + "android" ], "libc": [ "glibc"