来自 React Native 应用程序中冲突的 WebRTC 库的重复 class 错误

Duplicate class error from conflicting WebRTC library in React Native app

过去几天我一直在寻找解决方法,但无济于事。我仅将 Voximplant 用于即时消息 (IM),并希望将 Sinch 用于对其他应用程序的 VOIP 呼叫。由于 Sinch IM 不适合我们的用例,因此我们将 Voximplant 用于我首先实现的消息传递。

现在我无法使用 react-native-sinch-voip 进行构建,因为 Voximplant SDK 还包含 VOIP 功能,导致两个库在构建过程中 WebRTC classes 发生冲突。

我通过重命名 CallManager class 名称设法解决了 iOS 中的冲突,但无法解决 Android。

Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class org.webrtc.AddIceObserver found in modules jetified-sinch-android-rtc-4.8.6+b14862c-runtime (sinch-android-rtc-4.8.6+b14862c.aar) and jetified-voximplant-sdk-2.27.0-runtime (com.voximplant:voximplant-sdk:2.27.0)
     Duplicate class org.webrtc.AndroidVideoDecoder found in modules jetified-sinch-android-rtc-4.8.6+b14862c-runtime (sinch-android-rtc-4.8.6+b14862c.aar) and jetified-voximplant-sdk-2.27.0-runtime (com.voximplant:voximplant-sdk:2.27.0)
     Duplicate class org.webrtc.AndroidVideoDecoder found in modules jetified-sinch-android-rtc-4.8.6+b14862c-runtime (sinch-android-rtc-4.8.6+b14862c.aar) and jetified-voximplant-sdk-2.27.0-runtime (com.voximplant:voximplant-sdk:2.27.0)
     Duplicate class org.webrtc.AndroidVideoDecoder$DecodedTextureMetadata found in modules jetified-sinch-android-rtc-4.8.6+b14862c-runtime (sinch-android-rtc-4.8.6+b14862c.aar) and jetified-voximplant-sdk-2.27.0-runtime (com.voximplant:voximplant-sdk:2.27.0)
     Duplicate class org.webrtc.AndroidVideoDecoder$FrameInfo found in modules jetified-sinch-android-rtc-4.8.6+b14862c-runtime (sinch-android-rtc-4.8.6+b14862c.aar) and jetified-voximplant-sdk-2.27.0-runtime (com.voximplant:voximplant-sdk:2.27.0)
     Duplicate class org.webrtc.AudioDecoderFactoryFactory found in modules jetified-sinch-android-rtc-4.8.6+b14862c-runtime (sinch-android-rtc-4.8.6+b14862c.aar) and jetified-voximplant-sdk-2.27.0-runtime (com.voximplant:voximplant-sdk:2.27.0)
     Duplicate class org.webrtc.AudioEncoderFactoryFactory found in modules jetified-sinch-android-rtc-4.8.6+b14862c-runtime (sinch-android-rtc-4.8.6+b14862c.aar) and jetified-voximplant-sdk-2.27.0-runtime (com.voximplant:voximplant-sdk:2.27.0)
     Duplicate class org.webrtc.AudioProcessingFactory found in modules jetified-sinch-android-rtc-4.8.6+b14862c-runtime (sinch-android-rtc-4.8.6+b14862c.aar) and jetified-voximplant-sdk-2.27.0-runtime (com.voximplant:voximplant-sdk:2.27.0)
     Duplicate class org.webrtc.AudioSource found in modules jetified-sinch-android-rtc-4.8.6+b14862c-runtime (sinch-android-rtc-4.8.6+b14862c.aar) and jetified-voximplant-sdk-2.27.0-runtime (com.voximplant:voximplant-sdk:2.27.0)
     Duplicate class org.webrtc.AudioTrack found in modules jetified-sinch-android-rtc-4.8.6+b14862c-runtime (sinch-android-rtc-4.8.6+b14862c.aar) and jetified-voximplant-sdk-2.27.0-runtime (com.voximplant:voximplant-sdk:2.27.0)
     Duplicate class org.webrtc.BaseBitrateAdjuster found in modules jetified-sinch-android-rtc-4.8.6+b14862c-runtime (sinch-android-rtc-4.8.6+b14862c.aar) and jetified-voximplant-sdk-2.27.0-runtime (com.voximplant:voximplant-sdk:2.27.0)
     Duplicate class org.webrtc.BitrateAdjuster found in modules jetified-sinch-android-rtc-4.8.6+b14862c-runtime (sinch-android-rtc-4.8.6+b14862c.aar) and jetified-voximplant-sdk-2.27.0-runtime (com.voximplant:voximplant-sdk:2.27.0)
     Duplicate class org.webrtc.BuiltinAudioDecoderFactoryFactory found in modules jetified-sinch-android-rtc-4.8.6+b14862c-runtime (sinch-android-rtc-4.8.6+b14862c.aar) and jetified-voximplant-sdk-2.27.0-runtime (com.voximplant:voximplant-sdk:2.27.0)
     Duplicate class org.webrtc.BuiltinAudioEncoderFactoryFactory found in modules jetified-sinch-android-rtc-4.8.6+b14862c-runtime (sinch-android-rtc-4.8.6+b14862c.aar) and jetified-voximplant-sdk-2.27.0-runtime (com.voximplant:voximplant-sdk:2.27.0)
     Duplicate class org.webrtc.CallSessionFileRotatingLogSink found in modules jetified-sinch-android-rtc-4.8.6+b14862c-runtime (sinch-android-rtc-4.8.6+b14862c.aar) and jetified-voximplant-sdk-2.27.0-runtime (com.voximplant:voximplant-sdk:2.27.0)
...

我已经尝试了几个建议的解决方案,将以下代码添加到 app/build.gradle 但无法正常工作。不确定我是否也使用了正确的语法。我不熟悉原生 Android,因此寻求帮助。

implementation(project(':react-native-voximplant')){
    exclude group: 'com.voximplant', module:'org.webrtc.*'
}
configurations {
    all*.exclude module: 'org.webrtc.AndroidVideoDecoder'
}

很遗憾,无法将 Voximplant React Native SDK 与其他基于 WebRTC 的 SDK 一起使用。 Voximplant SDK 基于具有额外补丁的特定版本的 WebRTC 库,并且从 Voximplant 中排除 WebRTC 本机库 Android SDK 将导致未定义的行为。

我们目前正在对 Voximplant SDK 进行重大更新,这将允许在不依赖 WebRTC 的情况下使用 Voximplant 消息传递 API,但是完成此版本需要几个月的时间。