首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >反应导航抽屉给我不变的违规:模块AppRegistry不是一个注册的可调用模块

反应导航抽屉给我不变的违规:模块AppRegistry不是一个注册的可调用模块
EN

Stack Overflow用户
提问于 2022-01-14 12:06:06
回答 1查看 7.1K关注 0票数 3

我在另一个项目中遇到了问题,它指向了我正在使用的test导航抽屉,所以我决定打开一个测试文件,尝试重新创建这个问题。

我从ran导航网站复制代码并运行它,它给了我这个错误。

代码语言:javascript
运行
复制
ERROR  TypeError: undefined is not an object (evaluating 'InnerNativeModule.installCoreFunctions')
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling unmountApplicationComponentAtRootTag). A frequent cause of the error is that the application entry file path 
is incorrect.
      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
ialization error when loading React Native.

这是代码

代码语言:javascript
运行
复制
import 'react-native-gesture-handler';
import * as React from 'react';
import { View, Text } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createDrawerNavigator } from '@react-navigation/drawer';

function Feed() {
  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <Text>Feed Screen</Text>
    </View>
  );
}

function Article() {
  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <Text>Article Screen</Text>
    </View>
  );
}

const Drawer = createDrawerNavigator();

function MyDrawer() {
  return (
    <Drawer.Navigator>
      <Drawer.Screen name="Feed" component={Feed} />
      <Drawer.Screen name="Article" component={Article} />
    </Drawer.Navigator>
  );
}

export default function App() {
  return (
    <NavigationContainer>
      <MyDrawer />
    </NavigationContainer>
  );
}

这是我下载的软件包

代码语言:javascript
运行
复制
  "dependencies": {
    "@react-navigation/drawer": "^6.1.8",
    "@react-navigation/native": "^6.0.6",
    "react": "17.0.2",
    "react-native": "0.66.4",
    "react-native-gesture-handler": "^2.1.1",
    "react-native-reanimated": "^2.3.1",
    "react-native-safe-area-context": "^3.3.2",
    "react-native-screens": "^3.10.1"
  },

我在网上看到,我可能忘了下载什么东西,但我能搞清楚

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-01-16 09:17:41

因此~发生这种情况是因为没有正确安装react本机恢复(不变量冲突的常见原因:模块AppRegistry不是已注册的可调用模块),

要解决这个问题,只需按照react本机更新的网站https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/上的文档进行操作即可。

步骤1:在babel.config.js中

代码语言:javascript
运行
复制
    module.exports = {
      ...
      plugins: [
          ...
          'react-native-reanimated/plugin',//Add this
      ],
  };

第二步:在android/app/build.gradle中

代码语言:javascript
运行
复制
project.ext.react = [
  enableHermes: true  // <-change this to true
]

步骤3:在MainApplication.java中

代码语言:javascript
运行
复制
  import com.facebook.react.bridge.JSIModulePackage; // <- add
  import com.swmansion.reanimated.ReanimatedJSIModulePackage; // <- add
  ...
  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
  ...

      @Override
      protected String getJSMainModuleName() {
        return "index";
      }

///////////////////////////////////////////////////
      @Override
      protected JSIModulePackage getJSIModulePackage() {      <- add this block
        return new ReanimatedJSIModulePackage(); // 
      }
///////////////////////////////////////////////////
    };

步骤4:在航站楼

代码语言:javascript
运行
复制
cd android 
./gradlew clean
cd ../ 

第五步:为了安全起见

代码语言:javascript
运行
复制
npx react-native run-android -- --reset-cache   
票数 8
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70710318

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档