android - React Native Navigation React Native CLI 自动链接错误
问题描述
问题描述
npx react-native link react-native-navigation
我通过(并修改minSdkVersion
in andoid/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")
由于 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
解决方案
仅供参考,自 react-native-navigation@6.1.0 以来,链接脚本也已修复以更新minSDK
for android。
此外,您不应添加 react-native-navigation,react-native.config.js
因为需要在您的本机代码中使用 RNN 库。团队更新了文档以使安装指南更清晰:https ://wix.github.io/react-native-navigation/docs/installing 。如果您遵循指南,它应该非常简单。
推荐阅读
- sql-server - EF 将列数据作为列表或数组返回
- asp.net-core - 如何自定义 AspNetCore 3.x 身份视图?
- asp.net-core - 在剃刀页面中将数据作为 json 返回
- python - 如何在我的代码中查找并修复附近的“(”:语法错误
- flutter - Agora 云端录制:错误 404(Flutter + Google Cloud Function)
- ssl - Apache2 有时提供旧的 SSL 证书
- node.js - 如何使用queryInterface在续集迁移文件中传递偏执狂,下划线等选项
- functional-programming - Idris 在类型定义中使用 if 语句返回依赖类型签名错误
- android - 如何在 Kotlin 中使用编程设置约束
- python - None 使用 asyncio 阻止“while True”