简体   繁体   English

在 UIManager 中找不到“RNCSafeAreaView”

[英]"RNCSafeAreaView" was not found in the UIManager

I try to open a bundle, but when the android is running it shows the next message我尝试打开一个包,但是当 android 运行时它会显示下一条消息

2020-01-05 23:15:45.366 26210-26210/com.note.principal W/.note.principa: Accessing hidden field Landroid/view/View;->mAccessibilityDelegate:Landroid/view/View$AccessibilityDelegate; 2020-01-05 23:15:45.366 26210-26210/com.note.principal W/.note.principa:访问隐藏字段 Landroid/view/View;->mAccessibilityDelegate:Landroid/view/View$AccessibilityDelegate; (light greylist, reflection) 2020-01-05 23:15:45.470 26210-26242/com.note.principal E/ReactNativeJS: Invariant Violation: requireNativeComponent: "RNCSafeAreaView" was not found in the UIManager. (浅灰名单,反射) 2020-01-05 23:15:45.470 26210-26242/com.note.principal E/ReactNativeJS: Invariant Violation: requireNativeComponent: "RNCSafeAreaView" is not found in the UIManager.

 This error is located at: in RNCSafeAreaView in Unknown in Unknown in n in Unknown in Unknown in C in P in u in RCTView in RCTView in h 2020-01-05 23:15:45.494 26210-26242/com.note.principal E/ReactNativeJS: Invariant Violation: requireNativeComponent:

"RNCSafeAreaView" was not found in the UIManager.在 UIManager 中找不到“RNCSafeAreaView”。

 This error is located at: in P in u in RCTView in RCTView in h 2020-01-05 23:15:45.502 26210-26242/com.note.principal E/ReactNativeJS: Invariant Violation: requireNativeComponent:

"RNCSafeAreaView" was not found in the UIManager.在 UIManager 中找不到“RNCSafeAreaView”。

 This error is located at: in P in u in RCTView in RCTView in h 2020-01-05 23:15:45.794 26210-26244/com.note.principal E/unknown:ReactNative: Invariant Violation: requireNativeComponent:

"RNCSafeAreaView" was not found in the UIManager.在 UIManager 中找不到“RNCSafeAreaView”。

 This error is located at: in RNCSafeAreaView in Unknown in Unknown in n in Unknown in Unknown in C in P in u in RCTView in RCTView in h, stack: exports@175:1634 get@163:682 Al@89:70673 Ml@89:70108 Ul@89:67144 Ul@-1 Pl@89:65839 Pl@-1 <unknown>@89:25495 unstable_runWithPriority@168:3915 sn@89:25442 cn@89:25377 kl@89:64831 la@89:87813 render@89:90592 exports@342:541 run@334:1305 runApplication@334:2287 value@25:3685 <unknown>@25:841 value@25:2939 value@25:813 value@-1 2020-01-05 23:15:45.832 26210-26244/com.note.principal E/unknown:ReactNative: Invariant Violation: requireNativeComponent:

"RNCSafeAreaView" was not found in the UIManager.在 UIManager 中找不到“RNCSafeAreaView”。

 This error is located at: in P in u in RCTView in RCTView in h, stack: exports@175:1634 get@163:682 Al@89:70673 Ml@89:70108 Ul@89:67144 Ul@-1 Pl@89:65839 Pl@-1 <unknown>@89:25495 unstable_runWithPriority@168:3915 sn@89:25442 cn@89:25377 kl@89:64831 la@89:87813 render@89:90592 exports@342:541 run@334:1305 runApplication@334:2287 value@25:3685 <unknown>@25:841 value@25:2939 value@25:813 value@-1 2020-01-05 23:15:45.856 26210-26244/com.note.principal E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules Process: com.note.principal, PID: 26210 com.facebook.react.common.JavascriptException: Invariant Violation: requireNativeComponent: "RNCSafeAreaView" was not found in

the UIManager.界面管理器。

 This error is located at: in P in u in RCTView in RCTView in h, stack: exports@175:1634 get@163:682 Al@89:70673 Ml@89:70108 Ul@89:67144 Ul@-1 Pl@89:65839 Pl@-1 <unknown>@89:25495 unstable_runWithPriority@168:3915 sn@89:25442 cn@89:25377 kl@89:64831 la@89:87813 render@89:90592 exports@342:541 run@334:1305 runApplication@334:2287 value@25:3685 <unknown>@25:841 value@25:2939 value@25:813 value@-1 at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:71) at java.lang.reflect.Method.invoke(Native Method) at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:371) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:150) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:26) at android.os.Looper.loop(Looper.java:193) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:225) at java.lang.Thread.run(Thread.java:764) 2020-01-05 23:15:45.862 26210-26244/com.note.principal I/Process: Sending signal.

PID: 26210 SIG: 9 PID:26210 SIG:9

The package of project is项目包是

{
  "name": "Notes",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "bundle_android": "react-native bundle --entry-file index.js --platform android --dev false --bundle-output ./bundles/android/index.android.bundle",
    "bundle_ios": "react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ./bundles/ios/main.jsbundle",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-community/masked-view": "^0.1.5",
    "prop-types": "^15.7.2",
    "react": "16.9.0",
    "react-native": "0.61.5",
    "react-native-gesture-handler": "^1.5.3",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-safe-area-context": "^0.6.2",
    "react-navigation": "^4.0.10",
    "react-navigation-stack": "^2.0.8"
  },
  "devDependencies": {
    "@babel/core": "^7.7.7",
    "@babel/runtime": "^7.7.7",
    "@react-native-community/eslint-config": "^0.0.6",
    "babel-jest": "^24.9.0",
    "eslint": "^6.8.0",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.57.0",
    "react-test-renderer": "16.9.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

The project of gradle gradle的项目

include ':app'
rootProject.name='Notes'


include ':hermes-engine'
project(':hermes-engine').projectDir = new File(rootProject.projectDir, '../node_modules/hermes-engine/android/')

include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')

include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')



// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
        mavenLocal()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}




apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    defaultConfig {
        applicationId ""
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

project.ext.react = [
        enableHermes: false,
]

def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", false)

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation "com.facebook.react:react-native:+"
    implementation 'com.android.support:support-annotations:27.1.1'
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-linear-gradient')

    if (enableHermes) {
        implementation project(':hermes-engine')
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}

This is the code of activity这是活动代码

package com.note

import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.facebook.react.ReactInstanceManager
import com.facebook.react.ReactRootView
import com.facebook.react.common.LifecycleState
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler
import com.facebook.react.shell.MainReactPackage
import com.facebook.soloader.SoLoader
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage
import com.BV.LinearGradient.LinearGradientPackage

class ReactActivity : AppCompatActivity(), DefaultHardwareBackBtnHandler {

    private val OVERLAY_PERMISSION_REQ_CODE = 1

    private lateinit var mReactRootView: ReactRootView
    private lateinit var mReactInstanceManager: ReactInstanceManager

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        SoLoader.init(this, false)
        mReactRootView = ReactRootView(this)
        mReactInstanceManager = ReactInstanceManager.builder()
            .setApplication(application)
            .setCurrentActivity(this)
            .setApplication(application)
            .setBundleAssetName("aaaaaa.android.bundle")
            .addPackage(MainReactPackage())
            .addPackage(RNGestureHandlerPackage())
            .addPackage(LinearGradientPackage())
            .setInitialLifecycleState(LifecycleState.RESUMED)
            .build()
        // The string here (e.g. "MyReactNativeApp") has to match
        // the string in AppRegistry.registerComponent() in index.js
        mReactRootView.startReactApplication(mReactInstanceManager, "Notes", null)

        setContentView(mReactRootView)

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (!Settings.canDrawOverlays(this)) {
                val intent = Intent(
                        Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
                        Uri.parse("package:$packageName")
                )
                startActivityForResult(intent, OVERLAY_PERMISSION_REQ_CODE)
            }
        }
    }

    override fun invokeDefaultOnBackPressed() {
        super.onBackPressed()
    }

    override fun onBackPressed() {
        if (mReactInstanceManager != null) {
            mReactInstanceManager.onBackPressed()
        } else {
            super.onBackPressed()
        }
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        if (requestCode == OVERLAY_PERMISSION_REQ_CODE) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                if (!Settings.canDrawOverlays(this)) {
                    // SYSTEM_ALERT_WINDOW permission not granted
                }
            }
        }
        mReactInstanceManager?.onActivityResult(this,requestCode, resultCode, data)
    }
}

someone knows what is the solution?有人知道解决方案是什么?

I encountered the same error.我遇到了同样的错误。 In order to solve it make sure to install react-native-safe-area-context.为了解决它,请确保安装 react-native-safe-area-context。

npm install react-native-safe-area-context

Then if you are using React Native 0.61.X make sure to do a pod install .然后,如果您使用的是 React Native 0.61.X,请确保执行pod install It will link everything together.它将把一切联系在一起。

If you are using React Native < 0.6 then you need to do the linking manually with react-native link react-native-safe-area-context如果您使用的是 React Native < 0.6,那么您需要使用react-native link react-native-safe-area-context手动进行react-native link react-native-safe-area-context

I was searched and found the next,我被搜索并找到了下一个,

first, you need to clean the project首先,您需要清理项目

Second import modules at project项目中的第二个导入模块

include ':app'
rootProject.name='Notes'


include ':hermes-engine'
project(':hermes-engine').projectDir = new File(rootProject.projectDir, '../node_modules/hermes-engine/android/')

include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')

include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')

include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')

include ':react-native-safe-area-context'
project(':react-native-safe-area-context').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-safe-area-context/android')

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation "com.facebook.react:react-native:+"
    implementation 'com.android.support:support-annotations:27.1.1'
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-linear-gradient')
    implementation project(':react-native-safe-area-context')

    if (enableHermes) {
        implementation project(':hermes-engine')
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}


 override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        SoLoader.init(this, false)
        mReactRootView = ReactRootView(this)
        mReactInstanceManager = ReactInstanceManager.builder()
            .setApplication(application)
            .setCurrentActivity(this)
            .setApplication(application)
            .setBundleAssetName("index.android.bundle")
            .addPackage(MainReactPackage())
            .addPackage(RNGestureHandlerPackage())
            .addPackage(LinearGradientPackage())
            .addPackage(SafeAreaContextPackage())
            .addPackage(SDKCorePackage())
            .setInitialLifecycleState(LifecycleState.RESUMED)
            .build()
        // The string here (e.g. "MyReactNativeApp") has to match
        // the string in AppRegistry.registerComponent() in index.js
        mReactRootView.startReactApplication(mReactInstanceManager, "Notes", null)

        setContentView(mReactRootView)

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (!Settings.canDrawOverlays(this)) {
                val intent = Intent(
                        Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
                        Uri.parse("package:$packageName")
                )
                startActivityForResult(intent, OVERLAY_PERMISSION_REQ_CODE)
            }
        }
    }

i will hope that it will be useful, also this link helped me我希望它会有用,这个链接也帮助了我

react-native-safe-area-context 反应原生安全区域上下文

Below worked for me :以下为我工作:

  1. npm install react-native-safe-area-context npm install react-native-safe-area-context
  2. react-native link react-native-safe-area-context react-native 链接 react-native-safe-area-context
  3. List item项目清单
  4. inside android gradlew clean里面android gradlew干净
  5. npm start启动
  6. npm run android npm 运行安卓

In case you are NOT using ReactRootView (integrating existing apps to react-native)...如果您不使用 ReactRootView(将现有应用程序集成到 react-native)...

You probably still need to add your package (packages which don't support autolinking yet, ie, the new safe-area-view , for instance) to MainApplication.java :您可能仍需要将您的包(例如,尚不支持自动链接的包,即新的safe-area-view )添加到MainApplication.java

android/app/src/main/.../MainApplication.java

On top, where imports are:最重要的是,进口是:

import com.th3rdwave.safeareacontext.SafeAreaContextPackage;

Add the SafeAreaContextPackage class to your list of exported packages.将 SafeAreaContextPackage 类添加到导出的包列表中。

@Override
protected List<ReactPackage> getPackages() {
    return Arrays.asList(
            new MainReactPackage(),
            /**other packages of yours**/
            new SafeAreaContextPackage()
    );
}

Worked for me for below version and on iOS在以下版本和 iOS 上为我工作

"react": "16.9.0",
 "react-native": "0.61.5",

Step to resolve解决步骤

-Stop the current running Metro Bundler - 停止当前正在运行的 Metro Bundler

-install pod for ios - 为 ios 安装 pod

-try re-run the application - 尝试重新运行应用程序

Hope this will help !希望这会有所帮助!

I have the same problem, But I solved this problem.我有同样的问题,但我解决了这个问题。

npm install -g expo-cli npm install -g expo-cli

update expo更新博览会

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 UIManager 中找不到 RNCSafeAreaView - RNCSafeAreaView was not found in the UIManager 不变违规:不变违规:requireNativeComponent:在 UIManager 中找不到“RNCSafeAreaView”。 - Invariant Violation: Invariant Violation: requireNativeComponent: "RNCSafeAreaView" was not found in the UIManager." requireNativeComponent:在 UIManager 中找不到“RNSScreenStackHeaderConfig” - requireNativeComponent: "RNSScreenStackHeaderConfig" was not found in the UIManager 在 UIManager 中找不到 requireNativeComponent - requireNativeComponent was not found in UIManager 错误:在 UIManager 中找不到“ARTShape” - React native - Error : "ARTShape" was not found in the UIManager - React native 不变违规:requireNativeComponent:在 Android 的 UIManager 中找不到“RNSVGSvgViewAndroid” - Invariant Violation: requireNativeComponent: "RNSVGSvgViewAndroid" was not found in the UIManager in Android 安装 React Native Map。 在 UIManager 中找不到 AIRMap - Installing React Native Map. AIRMap not found in UIManager requireNativeComponent:运行 android 应用程序时,在 UIManager 中找不到“RNSScreenStackHeaderConfig” - requireNativeComponent: "RNSScreenStackHeaderConfig" was not found in the UIManager when running android app React-Native-SVG 错误:不变违规:requireNativeComponent:在 UIManager 中找不到“RNSVGGroup” - React-Native-SVG Error: Invariant Violation: requireNativeComponent: "RNSVGGroup" was not found in the UIManager 延迟回调中的异常:错误:路由器上未配置uiManager - Exception in defer callback: Error: No uiManager configured on Router
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM