Skip to content

How I fixed react-native-audio-api build on RN 0.85 (Windows, bash issue, JNI error) #1012

@FernandoAOborges

Description

@FernandoAOborges

Description

  1. Create a new React Native project using version 0.85.0

  2. Install react-native-audio-api:
    yarn add react-native-audio-api

  3. Run Android build on Windows:
    cd android
    ./gradlew assembleDebug

  4. Observe failure during task:
    :react-native-audio-api:downloadPrebuiltBinaries

  5. Error occurs:
    <3>WSL ERROR: execvpe(/bin/bash) failed: No such file or directory

  6. After fixing bash issue, build fails again with:
    fatal error: 'react/jni/CxxModuleWrapper.h' file not found

Steps to reproduce

Fix: react-native-audio-api on React Native 0.85 (Windows + Android build + bash + JNI)

Context

I was trying to use react-native-audio-api with:

React Native 0.85
Android (NDK 27)
Windows 10

During the Android build, I ran into multiple issues:

Problem 1 — downloadPrebuiltBinaries fails (bash issue)

Build error:

Task :react-native-audio-api:downloadPrebuiltBinaries FAILED
<3>WSL ERROR: execvpe(/bin/bash) failed: No such file or directory

Root cause

The Gradle task uses:

commandLine 'bash', '../scripts/download-prebuilt-binaries.sh'

On Windows, this resolves to:

C:\Windows\System32\bash.exe

Which points to WSL — and may be broken or unavailable.

✅ Fix 1 — Use Git Bash explicitly on Windows

Replace the task with a platform-aware executable:

task downloadPrebuiltBinaries(type: Exec) {
-  commandLine 'chmod', '+x', '../scripts/download-prebuilt-binaries.sh'
-  commandLine 'bash', '../scripts/download-prebuilt-binaries.sh'
-  args 'android', isFFmpegDisabled() ? 'skipffmpeg' : ''
+  def bashExecutable = Os.isFamily(Os.FAMILY_WINDOWS)
+    ? 'C:/Program Files/Git/usr/bin/bash.exe'
+    : 'bash'
+
+  commandLine bashExecutable, '../scripts/download-prebuilt-binaries.sh', 'android', isFFmpegDisabled() ? 'skipffmpeg' : ''
}

Important

If you're on Windows, make sure to adjust the path depending on your Git installation:

C:/Program Files/Git/usr/bin/bash.exe

Your path may vary.

❌ Problem 2 — JNI build failure (CxxModuleWrapper.h not found)

Error:

fatal error: 'react/jni/CxxModuleWrapper.h' file not found

Root cause

React Native 0.85 introduced changes in internal JNI headers.
CxxModuleWrapper.h is no longer available in the expected location.

✅ Fix 2 — Remove invalid includes

Remove the following include from multiple files:

- #include <react/jni/CxxModuleWrapper.h>

Files affected:

android/src/main/cpp/audioapi/android/AudioAPIModule.h
android/src/main/cpp/audioapi/android/core/NativeAudioPlayer.hpp
android/src/main/cpp/audioapi/android/core/NativeAudioRecorder.hpp
android/src/main/cpp/audioapi/android/system/NativeFileInfo.hpp

Notes
The chmod command in the original Gradle task is redundant (overwritten by the second commandLine)
The issue is not documented clearly, but partially related to:
Windows bash resolution
RN 0.85 native changes

Recommendation

Instead of editing node_modules directly, use patch-package:

npx patch-package react-native-audio-api

And commit the patch:

patches/react-native-audio-api+X.X.X.patch

Result

After applying both fixes:

downloadPrebuiltBinaries runs successfully
JNI compilation succeeds
Android build completes without errors
🙌 Hope this helps someone

This took quite some time to debug, so sharing in case others run into the same issues.

Snack or a link to a repository

I can provide a minimal reproduction repository if needed. This issue happens on a clean React Native 0.85.0 project on Windows after installing react-native-audio-api and running the Android build.

React Native Audio API version

^0.11.7

React Native version

0.85.0

Platforms

Android

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

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