当我导入此语句时
import {
RTCPeerConnection,
RTCIceCandidate,
RTCSessionDescription,
RTCView,
MediaStream,
MediaStreamTrack,
mediaDevices,
registerGlobals
} from 'react-native-webrtc';
此错误出现在我的博览会去(在android移动的):
错误类型错误:无法读取null的属性“senderGetCapabilities”,js引擎:爱马仕错误不变量违规:“main”尚未注册。这可能发生在以下情况:
- Metro(本地开发服务器)从错误的文件夹运行。检查Met ro是否正在运行,停止并在当前项目中重新启动。
- 由于错误,模块加载失败,并且未调用AppRegistry.registerCompon ent。,js引擎:爱马仕
"dependencies": {
"@config-plugins/react-native-webrtc": "^7.0.0",
"@expo-google-fonts/dev": "^0.2.3",
"@expo-google-fonts/heebo": "^0.2.3",
"@expo-google-fonts/inter": "^0.2.3",
"@expo-google-fonts/kanit": "^0.2.3",
"@expo-google-fonts/merriweather-sans": "^0.2.3",
"@expo-google-fonts/open-sans": "^0.2.3",
"@expo-google-fonts/patua-one": "^0.2.3",
"@expo-google-fonts/roboto": "^0.2.3",
"@expo-google-fonts/roboto-slab": "^0.2.3",
"@expo-google-fonts/rubik": "^0.2.3",
"@expo/webpack-config": "^19.0.0",
"@react-navigation/native": "^6.1.7",
"@react-navigation/native-stack": "^6.9.13",
"expo": "~49.0.8",
"expo-camera": "^13.4.3",
"expo-dev-client": "~2.4.8",
"expo-splash-screen": "^0.20.5",
"expo-status-bar": "~1.6.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.72.4",
"react-native-dotenv": "^3.4.9",
"react-native-vector-icons": "^10.0.0",
"react-native-web": "~0.19.6",
"react-native-webrtc": "^111.0.3",
"socket.io-client": "^4.7.2",
"validator": "^13.11.0"
}
平台信息:
React Native版本:“0.72.4”
WebRTC模块版本:“^111.0.3”
平台OS +版本:窗口:10
Expo Go:2.29.6
Chrome:116.0.5845.141
但是如果我不导入react-native-webrtc
,那么它运行得很顺利。我需要创建使用webrtc
的功能,如何解决这个问题?
1条答案
按热度按时间kwvwclae1#
react-native-webrc是原生代码,如果你想在Expo上使用它,你必须使用开发构建,遵循此文档https://docs.expo.dev/develop/development-builds/create-a-build/
并在app.json文件中添加permisson,如下所示