React Native Navigation React Native CLI自动链接错误

问题描述 投票:1回答:1

问题描述

我通过以下方式安装了这个库 npx react-native link react-native-navigation (并修改 minSdkVersionandoid/build.gradle).

当我运行npx react-native run-android时,应用程序被构建并正常运行,尽管我在终端得到以下错误。

error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually: 
  - react-native-navigation (to unlink run: "react-native unlink react-native-navigation")

由于类库已经被手动链接,我在 react-native.config.js 文件,以防止 react native 尝试自动链接库,如。

module.exports = {
    dependencies: {
        'react-native-navigation': {
            platforms: {
                android: null, // disable Android platform, other platforms will still autolink if provided
            },
        }
    }
  };

现在,CLI错误不再显示,应用程序也成功构建, 但我在模拟器中得到一个错误。

TypeError: null is not an object (evaluating "this.nativeCommandsModule.setRoot()").

这是在我第一次 Navigation.setRoot(...); 的调用。

[index.js]

const start = () => {
    Navigation.events().registerAppLaunchedListener(() => {
        registerScreens();
        gotoInitialising();
        // gotoLogin();
    });
};

start();

我的问题是,我应该采取什么额外的步骤 让lib工作,而不是有一个React Native CLI错误,在同一时间。

环境方面

React Native Navigation版本。6.0.1React Native版本。0.61.5平台(iOS, Android, 或两者都有?)。Android设备信息(SimulatorDevice?OS版本?DebugRelease?)。Android emulator API 28 - (emulator version 29.2.1-5889189) - Debug build

android react-native react-native-navigation wix-react-native-navigation
1个回答
0
投票

顺便说一下,自从[email protected],链接脚本已经被修正为更新了。minSDK 也是安卓系统的。

另外,你不应该在这里添加 react-native-navigation。react-native.config.js 因为在您的本地代码中需要使用 RNN 库。团队已经更新了文档,使安装指南更加清晰。https:/wix.github.ioreact-native-navigationdocsinstalling)。. 如果你按照指南,应该是很直接的。

© www.soinside.com 2019 - 2024. All rights reserved.