簡體   English   中英

在 UIManager 中找不到“RNSScreen”(僅限 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM