Resolving React Native libsodium CMake Build Errors on Windows

Overview

This guide addresses common build issues encountered when integrating react-native-libsodium into React Native projects, particularly on Windows environments. After extensive troubleshooting with various AI assistants (OpenAI, Claude, Gemini), I found that their suggested solutions often led to unnecessary complexity. This article provides straightforward solutions to avoid common pitfalls.

Environment Setup

The following configuration was used during development:

{
"react": "19.1.0",
"react-i18next": "^15.6.0",
"react-native": "0.80.1",
"react-native-libsodium": "^1.4.0"
}

Platform: Windows development environment
Target: Android build

Issue 1: CMakeLists.txt Path Escape Error

Problem

When running the Android build command, the following error occurs:

> npx react-native run-android
....
> Task :react-native-libsodium:configureCMakeDebug[arm64-v8a] FAILED
C/C++: CMake Warning (dev) in CMakeLists.txt:
C/C++: No project() command is present. The top-level CMakeLists.txt file must
C/C++: contain a literal, direct call to the project() command. Add a line of
C/C++: code such as
C/C++: project(ProjectName)
C/C++: near the top of the file, but after cmake_minimum_required().
C/C++: CMake is pretending…

Leave a Reply