不变违规:TurboModuleRegistry.getEnforcing(...): 'NativeReanimated' 找不到
Posted
技术标签:
【中文标题】不变违规:TurboModuleRegistry.getEnforcing(...): \'NativeReanimated\' 找不到【英文标题】:Invariant Violation: TurboModuleRegistry.getEnforcing(…): 'NativeReanimated' could not be found不变违规:TurboModuleRegistry.getEnforcing(...): 'NativeReanimated' 找不到 【发布时间】:2021-06-14 22:28:38 【问题描述】:在我的 React Native 应用程序中,我安装了 React Navigation,安装了 React Navigation Stack,最后安装了 Drawer Navigation。 如果我使用堆栈一切正常,但是当我尝试使用抽屉导航时,我会收到这个我无法解决的错误。 我已清除缓存,卸载“NativeReanimated”,重新安装, 在物理设备上测试...什么也没有,我找不到解决方案。
我已按照反应导航文档中的所有步骤进行操作,但什么也没做。 (https://reactnavigation.org/docs/getting-started 和 https://reactnavigation.org/docs/drawer-based-navigation)
节点版本:14.15.4.
在 Windows 上工作并使用 android。
我的 package.json:
"name": "themovieapp",
"version": "0.0.1",
"private": true,
"scripts":
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
,
"dependencies":
"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/drawer": "^5.12.4",
"@react-navigation/native": "^5.9.3",
"@react-navigation/stack": "^5.14.3",
"react": "17.0.1",
"react-native": "0.64.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-paper": "^4.7.2",
"react-native-reanimated": "^2.0.0",
"react-native-safe-area-context": "^3.2.0",
"react-native-screens": "^2.18.1",
"react-native-vector-icons": "^8.1.0"
,
"devDependencies":
"@babel/core": "^7.12.9",
"@babel/runtime": "^7.12.5",
"@react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "7.14.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.64.0",
"react-test-renderer": "17.0.1"[enter image description here][1]
,
"jest":
"preset": "react-native"
当我运行“react-native info”时:
OS: Windows 10 10.0.18363
CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
Memory: 4.60 GB / 15.93 GB
Binaries:
Node: 14.15.4 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 7.6.3 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 28, 29, 30
Build Tools: 28.0.3, 29.0.2, 30.0.2
System Images: android-28 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google Play Intel x86 Atom
Android NDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: Not Found
Visual Studio: Not Found
Languages:
Java: 1.8.0_275 - C:\Program Files\OpenJDK\openjdk-8u275-b01\bin\javac.EXE
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.1 => 17.0.1
react-native: 0.64.0 => 0.64.0
react-native-windows: Not Found
npmGlobalPackages:
*react-native*: Not Found
错误:https://i.stack.imgur.com/jcRCi.png
【问题讨论】:
作为临时解决方案,我已经安装了 react-native-reanimated 版本 1.13.2,它似乎可以工作...... react-native-reanimated GitHub 页面充满了相同的错误,所以看起来是自己库的错误。 【参考方案1】:https://docs.swmansion.com/react-native-reanimated/docs/installation/#babel-plugin
yarn add react-native-reanimated@next
将 Reanimated 的 babel 插件添加到你的 babel.config.js:'react-native-reanimated/plugin'
通过编辑 android/app/build.gradle 开启 Hermes 引擎:
在 MainApplication.java 中重新激活插件
https://docs.swmansion.com/react-native-gesture-handler/docs/
-
更新 MainActivity.java
首先在您的 index.js 文件中导入:
import 'react-native-gesture-handler';
完成...清除现金
-
yarn start --reset-cache
【讨论】:
以上是关于不变违规:TurboModuleRegistry.getEnforcing(...): 'NativeReanimated' 找不到的主要内容,如果未能解决你的问题,请参考以下文章