【发布时间】:2022-01-12 01:26:41
【问题描述】:
[已解决] 我正在开发一个 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 也可能会有所帮助。
【问题讨论】:
-
您是否为您的发布版本设置了程序规则?如果是这样,请同时发布您的 proguard 规则。
-
谢谢我已经弄清楚了,这是progurd问题。
-
@SadmanSamee 请您也可以将您的解决方案作为答案发布(而不是将其与您的问题混合)然后接受它作为批准的答案吗?谢谢。
-
@SadmanSamee 很高兴知道您已经解决了您的问题。 :)
-
@bruno-leveque 我们应该在哪里包含和放置 proguard 以及它的 txt 文件。请建议。我面临同样的问题。谢谢。