[英]Webrtc part crashes only on Release Build works fine on Debug build
[Solved] I am developing a Webrtc video chat application. [已解决]我正在开发一个 Webrtc 视频聊天应用程序。 It works fine on Debug build and doesn't crash but crashes on Release Build.它在 Debug 构建上运行良好,不会崩溃,但在 Release Build 上会崩溃。 My Webrtc version is我的 Webrtc 版本是
implementation 'org.webrtc:google-webrtc:1.0.27771'实施 'org.webrtc:google-webrtc:1.0.27771'
Whenever I call this function I get error每当我调用此函数时,我都会收到错误
# Fatal error in: ../../../../usr/local/google/home/sakal/code/webrtc-aar-release/src/sdk/android/src/jni/jni_generator_helper.cc, line 59 # 致命错误:../../../../usr/local/google/home/sakal/code/webrtc-aar-release/src/sdk/android/src/jni/jni_generator_helper.cc, line 59
And this is where it crashes,这就是它崩溃的地方,
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);
}
}
Solution解决方案
I have solved this problem.我已经解决了这个问题。 It was happening due to progurd issue.这是由于progurd问题而发生的。 simply putting简单地说
release {
consumerProguardFiles 'proguard-project.txt'
}
solved my problem.解决了我的问题。 Also this git repo might help. 这个 git repo也可能有帮助。
It was happening due to progurd issue. 这是由于progurd问题而发生的。 simply putting 简单地把
release {
consumerProguardFiles 'proguard-project.txt'
}
I was having the same problem and the solution was我遇到了同样的问题,解决方案是
Add file proguard-rules.pro
to the app
folder将文件proguard-rules.pro
添加到app
文件夹
## WebRTC
-keep class com.cloudwebrtc.webrtc.** { *; }
-keep class org.webrtc.** { *; }
and in build.gradle, add below 2 properties to buildTypes -> release并在 build.gradle 中,将以下 2 个属性添加到 buildTypes -> release
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.