【发布时间】:2020-02-29 21:35:37
【问题描述】:
问题描述
我通过npx react-native link react-native-navigation 安装了库(并修改了andoid/build.gradle 中的minSdkVersion)。
当我运行 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")
由于已经手动链接了 lib,我在 react-native.config.js 文件中添加了一个条目,以防止 react native 尝试自动链接 lib,如下所示:
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.1
React Native 版本:0.61.5
平台(iOS、Android 或两者?):Android
设备信息(模拟器/设备?操作系统版本?调试/发布?):Android emulator API 28 - (emulator version 29.2.1-5889189) - Debug build
【问题讨论】:
-
你得到的 TypeError 被抛出,因为 RNN 没有被链接。 minSdk 的问题应该在6.1.0 中解决
标签: android react-native react-native-navigation wix-react-native-navigation