代码之家  ›  专栏  ›  技术社区  ›  Vishal

TypeError:null不是对象(正在评估“WebRTCModule.peerConnectionInit”)

  •  0
  • Vishal  · 技术社区  · 3 年前

    嘿,伙计们,我有一段时间被这个webrtc的东西卡住了

    在弹出的expo应用程序中尝试获取对等连接时,我遇到以下错误:

    TypeError: null is not an object (evaluating 'WebRTCModule.peerConnectionInit')
    at node_modules\expo\build\environment\react-native-logs.fx.js:null in error
    at node_modules\react-native\Libraries\Core\ExceptionsManager.js:null in reportException
    at node_modules\react-native\Libraries\Core\ExceptionsManager.js:null in handleException
    at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:null in handleError
    at node_modules\expo\build\errors\ExpoErrorManager.js:null in errorHandler
    at node_modules\expo\build\errors\ExpoErrorManager.js:null in <anonymous>
    at node_modules\expo-error-recovery\build\ErrorRecovery.fx.js:null in ErrorUtils.setGlobalHandler$argument_0
    at node_modules\@babel\runtime\helpers\asyncToGenerator.js:null in asyncGeneratorStep
    at node_modules\@babel\runtime\helpers\asyncToGenerator.js:null in _next
    at node_modules\react-native\node_modules\promise\setimmediate\core.js:null in tryCallOne
    at node_modules\react-native\node_modules\promise\setimmediate\core.js:null in setImmediate$argument_0
    at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:null in _allocateCallback$argument_0
    at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:null in _callTimer
    at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:null in _callReactNativeMicrotasksPass
    at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:null in callReactNativeMicrotasks
    at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:null in __callReactNativeMicrotasks
    at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:null in __guard$argument_0
    at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:null in __guard
    at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:null in flushedQueue
    

    基于这个博客,我在android清单中添加了以下权限: https://github.com/react-native-webrtc/react-native-webrtc/blob/master/Documentation/AndroidInstallation.md

      <uses-feature android:name="android.hardware.audio.output" />
      <uses-feature android:name="android.hardware.microphone" />
      <uses-permission android:name="android.permission.RECORD_AUDIO" />
      <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
      <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
      <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
      <uses-permission android:name="android.permission.INTERNET" />
    

    我的代码很简单,即使我也能理解,但我不知道它为什么坏了。

    import {
        ScreenCapturePickerView,
        RTCPeerConnection,
        RTCIceCandidate,
        RTCSessionDescription,
        RTCView,
        MediaStream,
        MediaStreamTrack,
        mediaDevices,
        registerGlobals
    } from 'react-native-webrtc';
    
    
    export const createMyPeerConnection = () => {
        var peerConnection = null;
    
        let peerConstraints = {
                iceServers: [
                    {
                        urls: 'stun:stun.l.google.com:19302'
                    }
                ]
            };
            
            peerConnection = new RTCPeerConnection(peerConstraints);
    }
    

    我查看了一些现有的答案,但它们没有帮助: React Native: Error [TypeError: null is not an object (evaluating 'WebRTCModule.peerConnectionInit')]

    0 回复  |  直到 3 年前