如何在构建过程中解决此重复类错误?

我正在尝试在我的android应用程序中同时包含jitsi和opentok,并相应地进行切换。

这些是我的build.gradle(app)依赖项

//使用了opentok依赖

implementation files('libs/opentok-android-sdk-2.15.2.aar')

// jitsi依赖

implementation ('org.jitsi.react:jitsi-meet-sdk:2.5.0')

我的构建因类似这样的错误而失败

Duplicate class org.webrtc.AudioSource found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.AudioTrack found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.BaseBitrateAdjuster found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.BitrateAdjuster found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CallSessionFileRotatingLogSink found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.Camera1Capturer found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.Camera1Enumerator found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.Camera1Session found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.Camera1Session$1 found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.Camera1Session$2 found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.Camera1Session$SessionState found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.Camera2Capturer found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.Camera2Enumerator found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.Camera2Session found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.Camera2Session$1 found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.Camera2Session$CameraCaptureCallback found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.Camera2Session$CameraStateCallback found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.Camera2Session$CaptureSessionCallback found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.Camera2Session$SessionState found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraCapturer found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraCapturer$1 found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraCapturer$2 found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraCapturer$3 found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraCapturer$4 found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraCapturer$5 found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraCapturer$6 found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraCapturer$7 found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraCapturer$8 found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraCapturer$SwitchState found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraEnumerationAndroid found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraEnumerationAndroid$1 found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraEnumerationAndroid$2 found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraEnumerationAndroid$CaptureFormat found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraEnumerationAndroid$CaptureFormat$FramerateRange found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraEnumerationAndroid$ClosestComparator found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraEnumerator found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraSession found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraSession$CreateSessionCallback found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraSession$Events found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraSession$FailureType found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraVideoCapturer found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraVideoCapturer$CameraEventsHandler found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraVideoCapturer$CameraStatistics found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraVideoCapturer$CameraStatistics$1 found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraVideoCapturer$CameraSwitchHandler found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.CameraVideoCapturer$MediaRecorderHandler found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.ContextUtils found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.DataChannel found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.DataChannel$Buffer found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)
Duplicate class org.webrtc.DataChannel$Init found in modules jetified-opentok-android-sdk-2.15.2-runtime.jar (opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar (com.facebook.react:react-native-webrtc:1.75.2-jitsi-2994175)

谢谢,帮助我

yimao5788 回答:如何在构建过程中解决此重复类错误?

在我的例子中,我通过删除一些库解决了这个问题:确保你使用了两个库(一个在你的 gradle 中的实现中,另一个是一个库,所以它会产生重复错误)

  1. 实施组:'org.webrtc',名称:'google-webrtc',版本:'1.0.19742'
  2. 实现文件('libs/autobanh.jar')

在您的情况下,请确保删除两个库之一:((opentok-android-sdk-2.15.2.aar) 和 jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar)

解决办法: 删除第二个并使缓存无效并重新启动并享受:)

,

这两个依赖项都使用 WebRTC 并使用它们导入 org.webrtc, 我建议的最好方法是使用 Opentalk 源代码文件(而不是 aar 依赖项,如果可用)并使用这些文件并使用 Jitsi 本身附带的 webrtc 依赖项。考虑到您不能使用 Jitsi 源代码作为其第一个使用 React Native 依赖项编译的代码。

WebRTC 极大地增加了您的应用程序方面。无论如何,您都不想将其导入两次。

,

您正在寻找管理传递依赖项,解决冲突问题的通用方法是从带来它的依赖项之一中排除传递依赖

dependencies {
  compile('com.example.m:m:1.0') {
     exclude group: 'org.unwanted',module: 'x 
  }
  compile 'com.example.l:1.0'
}

您可以在 Gradle 的 dependency management 阅读更多内容。

,

这张快照向您展示了错误问题: enter image description here

本文链接:https://www.f2er.com/2798312.html

大家都在问