So, I choose to use react-native cli
over Expo
to make my app. As I was setting up, the biggest issue I encountered was the CMake
error and I was lost, but here are the sequence of solutions that I tried which resolved my problem!
Solutions I Tried
Install and Set Up Android Studio
- Open Android Studio and go to SDK Manager.
- Download the latest Android API, SDK Build-Tools, and NDK. > Update environment variables to include paths to Command-Line Tools and Platform Tools.
Ensure that the environment variables are updated to include the latest paths for Command-Line Tools and Platform Tools.
Simplify Java Environment Variables
- Ensure only one version of Java (e.g., Java 17 OpenJDK) is set in environment variables.
Locate and Edit CMakeLists.txt
- Locate
CMakeLists.txt
at:
D:\<Project-Name>\node_modules\react-native\ReactAndroid\cmake-utils\default-app-setup\
- Update its content to:
cmake_minimum_required(VERSION 3.13)
# Define the library name here.
project(appmodules)
# Check if the host system is Windows
if(CMAKE_HOST_WIN32)
# Replace backslashes in paths to forward slashes
string(REPLACE "\\" "/" REACT_ANDROID_DIR ${REACT_ANDROID_DIR})
endif()
# Include the ReactNative-application.cmake file
include(${REACT_ANDROID_DIR}/cmake-utils/ReactNative-application.cmake)
Top comments (0)