我创建一个新的 React Native 项目并安装 React Native Navigation 和 React Native Stack Navigation。
npm install @react-navigation/native
npm install @react-navigation/stack
npm install react-native-gesture-handler
我为此使用这些命令。版本都是最新的。
"dependencies": {
"@react-navigation/native": "^7.0.0",
"@react-navigation/stack": "^7.0.0",
"react": "18.3.1",
"react-native": "0.76.1",
"react-native-gesture-handler": "^2.20.2"},
这在运行时显示错误。
(node:16556) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
info Installing the app...
> Task :app:configureCMakeDebug[arm64-v8a] FAILED
C/C++: CMake Error at D:/React Native/ReactNative-Stylish-App/android/app/build/generated/autolinking/src/main/jni/Android-autolinking.cmake:9 (add_subdirectory):
C/C++: add_subdirectory called with incorrect number of arguments
C/C++: Call Stack (most recent call first):
C/C++: D:/React Native/ReactNative-Stylish-App/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:86 (include)
C/C++: CMakeLists.txt:31 (include)
C/C++: CMake Error at D:/React Native/ReactNative-Stylish-App/node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake:89 (target_link_libraries):
C/C++: Cannot specify link libraries for target
C/C++: "react_codegen_rngesturehandler_codegen" which is not built by this
C/C++: project.
C/C++: Call Stack (most recent call first):
C/C++: CMakeLists.txt:31 (include)
> Task :react-native-gesture-handler:compileDebugKotlin FAILED
55 actionable tasks: 24 executed, 31 up-to-date
请帮我解决这个问题。
这些错误是由文件夹名称中的空格引起的,例如
React Native
。
将名称更改为
ReactNative
后问题解决。