开发者问题收集

我该如何修复:TypeError:null 不是对象(评估“AgoraRtcChannelModule.prefix”)?

2021-05-20
1638

每次我将 RtcEngine 导入我的应用程序时( 从“react-native-agora”导入 RtcEngine; ),我都会收到以下错误:

TypeError: null is not an object (evaluating 'AgoraRtcChannelModule.prefix')
at node_modules\react-native\Libraries\LogBox\LogBox.js:148:8 in registerError
at node_modules\react-native\Libraries\LogBox\LogBox.js:59:8 in errorImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:33:4 in console.error
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:104:6 in reportException
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:171:19 in handleException
at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError
at node_modules\expo-error-recovery\build\ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:62:36 in tryCatch
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:288:29 in invoke
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:62:36 in tryCatch
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:152:27 in invoke
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:162:18 in Promise.resolve.then$argument_0
at node_modules\react-native\node_modules\promise\setimmediate\core.js:37:13 in tryCallOne
at node_modules\react-native\node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:130:14 in _callTimer
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:181:14 in _callImmediatesPass
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:441:30 in callImmediates
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:387:6 in __callImmediates
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:135:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:134:4 in flushedQueue
at [native code]:null in flushedQueue
at [native code]:null in invokeCallbackAndReturnFlushedQueue

Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
at node_modules\react-native\Libraries\LogBox\LogBox.js:148:8 in registerError
at node_modules\react-native\Libraries\LogBox\LogBox.js:59:8 in errorImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:33:4 in console.error
at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:104:6 in reportException
at node_modules\react-native\Libraries\Core\ExceptionsManager.js:171:19 in handleException
at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError
at node_modules\expo-error-recovery\build\ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:62:36 in tryCatch
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:288:29 in invoke
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:62:36 in tryCatch
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:152:27 in invoke
at node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:162:18 in Promise.resolve.then$argument_0
at node_modules\react-native\node_modules\promise\setimmediate\core.js:37:13 in tryCallOne
at node_modules\react-native\node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:130:14 in _callTimer
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:181:14 in _callImmediatesPass
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:441:30 in callImmediates
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:387:6 in __callImmediates
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:135:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:134:4 in flushedQueue
at [native code]:null in flushedQueue
at [native code]:null in invokeCallbackAndReturnFlushedQueue

注意:这是没有任何调用的情况。

任何帮助都将不胜感激。我对 react-native 和 javascript 还很陌生,所以我希望我已经提供了足够的信息。

2个回答

更新:
Expo 现在支持使用原生模块,而无需使用自定义开发客户端弹出到裸工作流,您可以在 此处 了解有关将它们与 Agora 结合使用的更多信息。

设置自定义开发客户端后,使用 expo run:iosexpo run:android 运行您的应用。

Ekaansh Arora
2021-06-29

我认为你没有正确使用 React Native。

我可能会建议你阅读文档并尝试最新版本:

附注:Agora React-Native SDK 不支持 Expo。

Akshat Gupta
2021-06-09