React Native安卓构建报错:Task :app:configureCMakeDebug[arm64-v8a]失败
Check and Fix Environment Variables
Ensure all path-related environment variables (likeANDROID_HOME,JAVA_HOME) use forward slashes (/) instead of backslashes (\). For example, changeC:\Android\SdktoC:/Android/Sdk. Edit these variables via System Properties > Advanced > Environment Variables.Update local.properties File
Navigate to your project'sandroiddirectory, open thelocal.propertiesfile. Modify path entries to use forward slashes. Example:sdk.dir=C:/Android/Sdk ndk.dir=C:/Android/Sdk/ndk/25.2.9519653If the file doesn't exist, create it and add these lines with your actual SDK/NDK paths.
Inspect CMakeLists.txt for Path Issues
Check anyCMakeLists.txtfiles in your project (including native dependencies) for paths using unescaped backslashes. Replace\with/or escape them as\\. For example, changeset(SOURCE_DIR C:\src)toset(SOURCE_DIR C:/src).Clear Node Modules and Reinstall Dependencies
Delete thenode_modulesfolder andpackage-lock.json(oryarn.lock), then runnpm install(oryarn install) to reinstall dependencies. This resolves issues from broken or misconfigured native modules.Switch to PowerShell or WSL
If using Command Prompt, try running the build command in PowerShell instead. Alternatively, use WSL (Windows Subsystem for Linux) for the build—Unix-style path formatting is more compatible with CMake.Verify NDK Installation and Path
Confirm you have the correct NDK version installed (check your project's build.gradle for requirements). Set the NDK path inlocal.propertiesor via theANDROID_NDK_HOMEenvironment variable, using forward slashes.
内容的提问来源于stack exchange,提问作者mukunda

