You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native集成reanimated后编译报错:Ninja与CMake相关问题

React Native集成Reanimated构建Android项目报错求助

环境与依赖详情

  • React Native版本:0.72.3
  • React Native Reanimated版本:^3.4.2
  • 设备:搭载M1芯片的Macbook Air,系统为macOS Ventura 13.0 (22A380)

package.json依赖片段

"dependencies": {
    "@react-native-async-storage/async-storage": "^1.19.1",
    "@react-navigation/bottom-tabs": "^6.5.8",
    "@react-navigation/drawer": "^6.6.3",
    "@react-navigation/native": "^6.1.7",
    "@react-navigation/native-stack": "^6.9.13",
    "@rneui/base": "^4.0.0-rc.7",
    "@rneui/themed": "^4.0.0-rc.8",
    "firebase": "^9.23.0",
    "react": "18.2.0",
    "react-native": "0.72.3",
    "react-native-dotenv": "^3.4.9",
    "react-native-gesture-handler": "^2.12.1",
    "react-native-reanimated": "^3.4.2",
    "react-native-safe-area-context": "^4.7.1",
    "react-native-screens": "^3.24.0",
    "react-native-vector-icons": "^10.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/eslint-config": "^0.72.2",
    "@react-native/metro-config": "^0.72.9",
    "@tsconfig/react-native": "^3.0.0",
    "@types/react": "^18.0.24",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.2.1",
    "jest": "^29.2.1",
    "metro-react-native-babel-preset": "0.76.7",
    "prettier": "^2.4.1",
    "react-test-renderer": "18.2.0",
    "typescript": "4.8.4"
  },
  "engines": {
    "node": ">=16"
  }

(注:已修正devDependencies中@babel/preset-env'的多余单引号)

初始构建报错

执行react-native run-android时出现以下错误:

[CXX1416] Could not find Ninja on PATH or in SDK CMake bin folders.
[CXX1416] Could not find Ninja on PATH or in SDK CMake bin folders.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':react-native-reanimated'.
> [CXX1416] Could not find Ninja on PATH or in SDK CMake bin folders.

完整错误日志:

> react-native run-android

info Starting JS server...

info Tip: Make sure that you have set up your development environment correctly, by running react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor

[CXX1416] Could not find Ninja on PATH or in SDK CMake bin folders.
[CXX1416] Could not find Ninja on PATH or in SDK CMake bin folders.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':react-native-reanimated'.
> [CXX1416] Could not find Ninja on PATH or in SDK CMake bin folders.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with ——info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 53s
error Failed to install the app. Command failed with exit code 1: ./gradlew tasks
[CXX1416] Could not find Ninja on PATH or in SDK CMake bin folders.
[CXX1416] Could not find Ninja on PATH or in SDK CMake bin folders. FAILURE: Build failed with an exception. * What went wrong:
A problem occurred configuring project ':react-native-reanimated'.
> [CXX1416] Could not find Ninja on PATH or in SDK CMake bin folders. * Try:
> Run with --stacktrace option to get the stack trace.
> Run with ——info or --debug option to get more log output.
> Run with ——scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 53s
> Task :gradle-plugin:pluginDescriptors
> Task :gradle-plugin:processResources
> Task :gradle-plugin:compileKotlin
> Task :gradle-plugin:compileJava NO-SOURCE
> Task :gradle-plugin:classes
> Task :gradle-plugin:jar
> Task :gradle-plugin:inspectClassesForKotlinIC > Configure project :react-native-reanimated
No AAR for react-native-reanimated found. Attempting to build from source.
Android gradle plugin: 7.4.2
Gradle: 8.0.1
WARNING: Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.
5 actionable tasks: 5 executed.

尝试解决后的新报错

推测是Ninja未安装或PATH配置问题,执行以下操作:

  1. 通过brew install ninja安装Ninja
  2. 清理构建缓存:
cd android
./gradlew clean
  1. 重启项目

但出现新错误:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-reanimated:configureCMakeDebug[arm64-v8a]'.
> [CXX1428] exception while building Json A problem occurred starting process 'command '/Users/meenachijuhomi/Library/Android/sdk/cmake/3.22.1/bin/cmake''

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with ——info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 48s
info Run CLI with --verbose flag for more details.

现寻求该问题的有效解决方案。


内容的提问来源于stack exchange,提问作者DineshMsd

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 01:59:50