Webrtc部分仅在Release Build上崩溃才可以在Debug上正常运行

时间:2019-05-09 17:28:02

标签: java android webrtc

[已解决] ,我正在开发Webrtc视频聊天应用程序。它在Debug版本上运行良好,不会崩溃,但在Release Build上崩溃。我的Webrtc版本是

  

实现'org.webrtc:google-webrtc:1.0.27771'

每当我调用此函数时,都会出错

  

#致命错误:   ../../../../usr/local/google/home/sakal/code/webrtc-aar-release/src/sdk/android/src/jni/jni_generator_helper.cc,   第59

这就是它崩溃的地方,

    public void start() {

        if (Nammu.checkPermission(CAMERA)) {

            //NEW
            PeerConnectionFactory.InitializationOptions initializationOptions =
                    PeerConnectionFactory.InitializationOptions.builder(this)
                            //.setEnableVideoHwAcceleration(true)
                            .setEnableInternalTracer(true)
                            //.setFieldTrials("WebRTC-FlexFEC-03/Enabled/")
                            .createInitializationOptions();
            PeerConnectionFactory.initialize(initializationOptions);


            PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
            DefaultVideoEncoderFactory defaultVideoEncoderFactory = new DefaultVideoEncoderFactory(
                    rootEglBase.getEglBaseContext(),  /* enableIntelVp8Encoder */true,  /* enableH264HighProfile */false);
            DefaultVideoDecoderFactory defaultVideoDecoderFactory = new DefaultVideoDecoderFactory(rootEglBase.getEglBaseContext());


            //NEW
        peerConnectionFactory = PeerConnectionFactory.builder()
                .setOptions(options)
                .setVideoEncoderFactory(defaultVideoEncoderFactory)
                .setVideoDecoderFactory(defaultVideoDecoderFactory)
                .createPeerConnectionFactory();

            VideoCapturer videoCapturerAndroid;
            videoCapturerAndroid = createCameraCapturer(new Camera1Enumerator(false));


            audioConstraints = new MediaConstraints();
            videoConstraints = new MediaConstraints();
            sdpConstraints = new MediaConstraints();

            if (videoCapturerAndroid != null) {

                //NEW
            SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create("CaptureThread", rootEglBase.getEglBaseContext());
            videoSource = peerConnectionFactory.createVideoSource(videoCapturerAndroid.isScreencast());
            videoCapturerAndroid.initialize(surfaceTextureHelper, getApplicationContext(), videoSource.getCapturerObserver());

            }
            localVideoTrack = peerConnectionFactory.createVideoTrack("100", videoSource);

            //create an AudioSource instance
            audioSource = peerConnectionFactory.createAudioSource(audioConstraints);

            localAudioTrack = peerConnectionFactory.createAudioTrack("101", audioSource);
            localAudioTrack.setEnabled(true);
            localAudioTrack.setVolume(1);

            if (videoCapturerAndroid != null) {
                videoCapturerAndroid.startCapture(1024, 720, 30);
            }

            localVideoTrack.addSink(localVideoView);

            localVideoView.setMirror(true);
            remoteVideoView.setMirror(true);

            gotUserMedia = true;
            if (SignallingClient.getInstance().isInitiator) {
                onTryToStart();
            }
        }else {
            Nammu.askForPermission(this, CAMERA, permissionCameraCallback);
        }
    }

解决方案

我已经解决了这个问题。这是由于progurd问题而发生的。 只需将

        release {
            consumerProguardFiles 'proguard-project.txt'
        }

解决了我的问题。 this git repo也可能会有所帮助。

1 个答案:

答案 0 :(得分:0)

这是由于问题问题而发生的。只需放

    release {
        consumerProguardFiles 'proguard-project.txt'
    }