From cbd60a408d559772c4c6dc43d9c4aeb83ce78af9 Mon Sep 17 00:00:00 2001 From: Kevin Lago Date: Sat, 25 Apr 2026 12:50:29 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20Windows=20build=20failures=20in=20Androi?= =?UTF-8?q?d=20=E2=80=94=20bash=20path=20and=20CMake/Ninja=20absolute=20pa?= =?UTF-8?q?th=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Windows, two problems block the Android build: 1. Gradle's downloadPrebuiltBinaries task calls 'bash' which resolves to the WSL relay (C:\Windows\System32\bash.exe). If WSL has no distro installed, this fails with: execvpe(/bin/bash) failed: No such file or directory Fix: detect Windows via Os.isFamily(Os.FAMILY_WINDOWS) and use Git Bash (C:\Program Files\Git\usr\bin\bash.exe) instead. 2. CMake/Ninja generates object file paths from absolute source file paths. On Windows, Ninja converts the drive letter colon (C:) to an underscore (C_), producing a path like: CMakeFiles/react-native-audio-api.dir/C_/Users/.../audioapi which it cannot mkdir, failing with: ninja: error: mkdir(...C_/Users/...): No such file or directory Fix: convert absolute glob results to relative paths via file(RELATIVE_PATH) before passing them to add_library, so Ninja creates simple relative object directories with no drive letter. Fixes #784 (Ninja mkdir error on Windows) Fixes #1012 (bash not found on Windows) --- .../android/build.gradle | 11 ++++++++--- .../src/main/cpp/audioapi/CMakeLists.txt | 19 ++++++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/packages/react-native-audio-api/android/build.gradle b/packages/react-native-audio-api/android/build.gradle index e2b8442a8..b46b11c9e 100644 --- a/packages/react-native-audio-api/android/build.gradle +++ b/packages/react-native-audio-api/android/build.gradle @@ -308,9 +308,14 @@ def assertMinimalReactNativeVersion = task assertMinimalReactNativeVersionTask { } task downloadPrebuiltBinaries(type: Exec) { - commandLine 'chmod', '+x', '../scripts/download-prebuilt-binaries.sh' - commandLine 'bash', '../scripts/download-prebuilt-binaries.sh' - args 'android', isFFmpegDisabled() ? 'skipffmpeg' : '' + def isWindows = Os.isFamily(Os.FAMILY_WINDOWS) + if (isWindows) { + commandLine 'C:\\Program Files\\Git\\usr\\bin\\bash.exe', '../scripts/download-prebuilt-binaries.sh', 'android', isFFmpegDisabled() ? 'skipffmpeg' : '' + } else { + commandLine 'chmod', '+x', '../scripts/download-prebuilt-binaries.sh' + commandLine 'bash', '../scripts/download-prebuilt-binaries.sh' + args 'android', isFFmpegDisabled() ? 'skipffmpeg' : '' + } } // Make preBuild depend on the download task diff --git a/packages/react-native-audio-api/android/src/main/cpp/audioapi/CMakeLists.txt b/packages/react-native-audio-api/android/src/main/cpp/audioapi/CMakeLists.txt index b96e3f282..f533ea1be 100644 --- a/packages/react-native-audio-api/android/src/main/cpp/audioapi/CMakeLists.txt +++ b/packages/react-native-audio-api/android/src/main/cpp/audioapi/CMakeLists.txt @@ -1,8 +1,21 @@ cmake_minimum_required(VERSION 3.12.0) -file(GLOB_RECURSE ANDROID_CPP_SOURCES CONFIGURE_DEPENDS "${ANDROID_CPP_DIR}/audioapi/*.cpp") -file(GLOB_RECURSE COMMON_CPP_SOURCES CONFIGURE_DEPENDS "${COMMON_CPP_DIR}/audioapi/*.cpp" "${COMMON_CPP_DIR}/audioapi/*.c") -file(GLOB_RECURSE DSP_CPP_SOURCES CONFIGURE_DEPENDS "${COMMON_CPP_DIR}/audioapi/dsp/*.cpp") +file(GLOB_RECURSE ANDROID_CPP_SOURCES_ABS CONFIGURE_DEPENDS "${ANDROID_CPP_DIR}/audioapi/*.cpp") +file(GLOB_RECURSE COMMON_CPP_SOURCES_ABS CONFIGURE_DEPENDS "${COMMON_CPP_DIR}/audioapi/*.cpp" "${COMMON_CPP_DIR}/audioapi/*.c") +file(GLOB_RECURSE DSP_CPP_SOURCES_ABS CONFIGURE_DEPENDS "${COMMON_CPP_DIR}/audioapi/dsp/*.cpp") + +foreach(src IN LISTS ANDROID_CPP_SOURCES_ABS) + file(RELATIVE_PATH rel_src "${CMAKE_CURRENT_SOURCE_DIR}" "${src}") + list(APPEND ANDROID_CPP_SOURCES "${rel_src}") +endforeach() +foreach(src IN LISTS COMMON_CPP_SOURCES_ABS) + file(RELATIVE_PATH rel_src "${CMAKE_CURRENT_SOURCE_DIR}" "${src}") + list(APPEND COMMON_CPP_SOURCES "${rel_src}") +endforeach() +foreach(src IN LISTS DSP_CPP_SOURCES_ABS) + file(RELATIVE_PATH rel_src "${CMAKE_CURRENT_SOURCE_DIR}" "${src}") + list(APPEND DSP_CPP_SOURCES "${rel_src}") +endforeach() if (RN_AUDIO_API_FFMPEG_DISABLED) list(REMOVE_ITEM COMMON_CPP_SOURCES