![](/img/trans.png)
[英]Invariant Violation: requireNativeComponent: "RNSVGSvgViewAndroid" was not found in the UIManager in Android
[英]"RNSScreen" was not found in the UIManager (Android only)
几天来我一直无法运行我的 React Native 应用程序。 我正在从一个依赖关系问题转到另一个问题......
这里的最后一个问题,我无法解决。 当我运行应用程序时,我收到此错误消息(请参阅问题底部的完整错误消息):
Invariant Violation: requireNativeComponent: "RNSScreen" was not found in the UIManager.
我找到了这个线程,但似乎没有一个答案对我有用,而且我只在 Android 上遇到问题 - iOS 版本运行良好。 我已经安装了最新版本的所有建议依赖项,我有干净的 npn 和反应本机缓存,在我的设备上重新安装了应用程序等等。
我不想初始化一个新项目并将所有代码等移至此,但如果我没有很快得到有效答案,这似乎是最终的解决方案......
让我知道你的想法。
更新(2021 年 11 月 20 日)
我启动了一个新的 React Native 项目并重新安装了所有依赖项。 我可以在 XCode 中运行该应用程序并在我的 iOS 设备上运行它,但在 Android Studio 中运行该应用程序,但我最终得到相同的错误消息:
Invariant Violation: requireNativeComponent: "RNSScreen" was not found in the UIManager.
这是package.json
文件的内容:
{
"name": "MyReactNativeApplication",
"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": {
"@bam.tech/react-native-make": "^3.0.3",
"@react-native-async-storage/async-storage": "^1.15.11",
"@react-native-clipboard/clipboard": "^1.9.0",
"@react-native-community/cli": "^6.2.0",
"@react-native-community/datetimepicker": "^3.5.2",
"@react-native-community/masked-view": "^0.1.11",
"@react-native-community/push-notification-ios": "^1.10.0",
"@react-native-firebase/app": "^12.9.3",
"@react-native-seoul/masonry-list": "^1.1.1",
"@react-navigation/bottom-tabs": "^6.0.9",
"@react-navigation/material-top-tabs": "^6.0.6",
"@react-navigation/native": "^6.0.6",
"@react-navigation/stack": "^6.0.11",
"react": "17.0.2",
"react-native": "0.66.3",
"react-native-actionsheet": "^2.4.2",
"react-native-add-calendar-event": "^4.0.0",
"react-native-admob": "^2.0.0-beta.6",
"react-native-admob-native-ads": "^0.4.1",
"react-native-animatable": "^1.3.3",
"react-native-autolink": "^4.0.0",
"react-native-calendars": "^1.1268.0",
"react-native-code-input": "^1.0.6",
"react-native-confirmation-code-field": "^7.1.0",
"react-native-contacts": "^7.0.2",
"react-native-eject": "^0.1.2",
"react-native-elements": "^3.4.2",
"react-native-event-listeners": "^1.0.7",
"react-native-fast-image": "^8.5.11",
"react-native-gesture-handler": "^1.10.3",
"react-native-get-location": "^2.1.2",
"react-native-haptic-feedback": "^1.13.0",
"react-native-image-picker": "^4.3.0",
"react-native-input-scroll-view": "^1.11.0",
"react-native-localize": "^2.1.5",
"react-native-maps": "^0.28.1",
"react-native-modal-datetime-picker": "^10.2.0",
"react-native-notifications": "^4.1.2",
"react-native-pager-view": "^5.4.9",
"react-native-parallax-scroll-view": "^0.21.3",
"react-native-parallax-scrollview": "^3.0.0",
"react-native-push-notification": "^8.1.1",
"react-native-reanimated": "^2.2.4",
"react-native-rheostat": "^1.0.2",
"react-native-safe-area": "^0.5.1",
"react-native-safe-area-context": "^3.3.2",
"react-native-screens": "^3.9.0",
"react-native-segmented-control-tab": "^3.4.1",
"react-native-slider": "^0.11.0",
"react-native-snap-carousel": "^3.9.1",
"react-native-svg": "^12.1.1",
"react-native-tab-view": "^3.1.1",
"react-native-tracking-transparency": "^0.1.1",
"react-native-vector-icons": "^8.1.0",
"react-native-video": "^5.2.0",
"react-navigation": "^4.4.4",
"rn-segmented-control": "^0.2.8",
"rn-sliding-up-panel": "^2.4.5",
"yarn": "^1.22.17"
},
"devDependencies": {
"@babel/core": "^7.16.0",
"@babel/runtime": "^7.16.3",
"@react-native-community/eslint-config": "^3.0.1",
"babel-jest": "^27.3.1",
"eslint": "^8.2.0",
"jest": "^27.3.1",
"metro-react-native-babel-preset": "^0.66.2",
"react-test-renderer": "17.0.2"
},
"jest": {
"preset": "react-native"
}
}
更新(21/11/2021)
完整的错误信息:
ERROR Invariant Violation: requireNativeComponent: "RNSScreen" was not found in the UIManager.
This error is located at:
in RNSScreen (at createAnimatedComponent.js:242)
in AnimatedComponent (at createAnimatedComponent.js:295)
in AnimatedComponentWrapper (at src/index.native.tsx:208)
in Screen (at Screens.tsx:37)
in MaybeScreen (at CardStack.tsx:642)
in RNSScreenContainer (at src/index.native.tsx:277)
in ScreenContainer (at Screens.tsx:20)
in MaybeScreenContainer (at CardStack.tsx:561)
in RCTView (at View.js:32)
in View (at Background.tsx:13)
in Background (at CardStack.tsx:559)
in CardStack (at StackView.tsx:437)
in RCTView (at View.js:32)
in View (at SafeAreaProviderCompat.tsx:42)
in SafeAreaProviderCompat (at StackView.tsx:430)
in RCTView (at View.js:32)
in View (at GestureHandlerRootView.android.tsx:21)
in GestureHandlerRootView (at StackView.tsx:429)
in StackView (at createStackNavigator.tsx:118)
in Unknown (at createStackNavigator.tsx:117)
in StackNavigator (at App.js:244)
in LandingStack (at SceneView.tsx:126)
in StaticContainer
in EnsureSingleNavigator (at SceneView.tsx:118)
in SceneView (at useDescriptors.tsx:210)
in RCTView (at View.js:32)
in View (at CardContainer.tsx:280)
in RCTView (at View.js:32)
in View (at CardContainer.tsx:278)
in RCTView (at View.js:32)
in View (at CardSheet.tsx:33)
in CardSheet (at Card.tsx:557)
in RCTView (at View.js:32)
in View (at createAnimatedComponent.js:242)
in AnimatedComponent (at createAnimatedComponent.js:295)
in AnimatedComponentWrapper (at Card.tsx:536)
in PanGestureHandler (at GestureHandlerNative.tsx:14)
in PanGestureHandler (at Card.tsx:530)
in RCTView (at View.js:32)
in View (at createAnimatedComponent.js:242)
in AnimatedComponent (at createAnimatedComponent.js:295)
in AnimatedComponentWrapper (at Card.tsx:526)
in RCTView (at View.js:32)
in View (at Card.tsx:520)
in Card (at CardContainer.tsx:218)
in CardContainer (at CardStack.tsx:649)
in MaybeFreeze (at src/index.native.tsx:229)
in RNSScreen (at createAnimatedComponent.js:242)
in AnimatedComponent (at createAnimatedComponent.js:295)
in AnimatedComponentWrapper (at src/index.native.tsx:208)
in Screen (at Screens.tsx:37)
in MaybeScreen (at CardStack.tsx:642)
in RNSScreenContainer (at src/index.native.tsx:277)
in ScreenContainer (at Screens.tsx:20)
in MaybeScreenContainer (at CardStack.tsx:561)
in RCTView (at View.js:32)
in View (at Background.tsx:13)
in Background (at CardStack.tsx:559)
in CardStack (at StackView.tsx:437)
in RNCSafeAreaProvider (at SafeAreaContext.tsx:76)
in SafeAreaProvider (at SafeAreaProviderCompat.tsx:46)
in SafeAreaProviderCompat (at StackView.tsx:430)
in GestureHandlerRootView (at GestureHandlerRootView.android.tsx:26)
in GestureHandlerRootView (at StackView.tsx:429)
in StackView (at createStackNavigator.tsx:118)
in Unknown (at createStackNavigator.tsx:117)
in StackNavigator (at App.js:710)
in EnsureSingleNavigator (at BaseNavigationContainer.tsx:430)
in BaseNavigationContainer (at NavigationContainer.tsx:132)
in ThemeProvider (at NavigationContainer.tsx:131)
in NavigationContainerInner (at App.js:689)
in App (at renderApplication.js:50)
in RCTView (at View.js:32)
in View (at AppContainer.js:92)
in RCTView (at View.js:32)
in View (at AppContainer.js:119)
in AppContainer (at renderApplication.js:43)
in MyReactNativeApplication(RootComponent) (at renderApplication.js:60)
WARN Possible Unhandled Promise Rejection (id: 0):
Invariant Violation: requireNativeComponent: "RNSScreen" was not found in the UIManager.
invariant@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:2391:26
getNativeComponentAttributes@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:53270:48
http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:52823:28
createInstance@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:7143:46
completeWork@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:14962:48
completeUnitOfWork@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:17830:34
performUnitOfWork@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:17807:29
workLoopSync@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:17736:28
renderRootSync@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:17712:25
performSyncWorkOnRoot@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:17473:40
performSyncWorkOnRoot@[native code]
flushSyncCallbacks@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:7798:36
flushSyncCallbacksOnlyInLegacyMode@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:7779:29
scheduleUpdateOnFiber@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:17160:49
dispatchAction@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:11805:43
dispatchAction@[native code]
_callee$@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:251553:27
tryCatch@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:24265:23
invoke@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:24435:32
tryCatch@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:24265:23
invoke@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:24337:30
http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:24347:21
tryCallOne@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:28942:16
http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:29043:27
http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:29634:26
_callTimer@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:29530:17
_callReactNativeMicrotasksPass@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:29569:17
callReactNativeMicrotasks@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:29779:44
__callReactNativeMicrotasks@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:3049:46
http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:2827:45
__guard@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:3032:15
flushedQueue@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.MyReactNativeApplication.app&modulesOnly=false&runModule=true:2826:21
flushedQueue@[native code]
callFunctionReturnFlushedQueue@[native code]
更新(2021 年 11 月 24 日)
尚未找到解决方案。 删除我的大部分app.js
文件时,我可以运行我的应用程序。 我可以保留所有导入,设置所有变量并渲染一些东西,但看看这个......
这能够运行:
render() {
const LoadingRootStack = createStackNavigator();
return (
<NavigationContainer linking={linking} fallback={<Text>Loading...</Text>}>
<View>
<Text>hello world</Text>
</View>
</NavigationContainer>
);
}
但这导致了上面的错误:
render() {
const LoadingRootStack = createStackNavigator();
return (
<NavigationContainer linking={linking} fallback={<Text>Loading...</Text>}>
<View>
<Text>hello world</Text>
</View>
<LoadingRootStack.Navigator initialRouteName="Loading">
<LoadingRootStack.Screen name="Loading" component={LoadingStack} options={{headerShown:false}}/>
</LoadingRootStack.Navigator>
</NavigationContainer>
);
}
我已经检查了createStackNavigator
/ @react-navigation/stack
的安装,但一切似乎都很好......
请帮我: :-)
不久前我遇到了同样的问题-如果有人知道的话,请说出来<3
我已经在 reddit 上联系了 Simon,我们解决了这个问题。
该项目的导航配置错误,Android 项目有很多旧版本的 React Native 遗留下来的东西。 该项目也没有被jetified
。
最奇怪的是,在项目清理和正确配置导航之后,错误仍然存在。 What potentially fixed it was the implementation of Multidex
on MainApplication.java
and removal of import com.facebook.react.shell.MainReactPackage
+ import androidx.multidex.MultiDex;
- import com.facebook.react.shell.MainReactPackage;
+ @Override
+ protected void attachBaseContext(Context base) {
+ super.attachBaseContext(base);
+ MultiDex.install(this);
+ }
android/app/build.gradle
defaultConfig {
applicationId "xxxxx"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true
}
...
dependencies {
implementation 'androidx.multidex:multidex:2.0.1'
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.