How to fix this Duplicate class error during build?
Asked Answered
C

4

6

I am trying to have both jitsi and opentok in my android application, and switch them accordingingly.

These are my build.gradle(app) dependencies

//opentok dependency used

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

//jitsi dependency used

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

My build failed with an error like this

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)

Thanks,help me out with this

Customhouse answered 9/1, 2020 at 11:3 Comment(1)
Good question. Did you find a solution?Premolar
T
0

In my case I resolved the problem with remove some library :Make sure that you are used two library (one in the implementation in your gradle and other is a library so it produces a duplication error)

  1. implementation group: 'org.webrtc', name: 'google-webrtc', version: '1.0.19742'
  2. implementation files('libs/autobanh.jar')

In your case make sure to remove one of two library :((opentok-android-sdk-2.15.2.aar) and jetified-react-native-webrtc-1.75.2-jitsi-2994175-runtime.jar)

Solution: Remove the second and invalidate the cache and restart and enjoy :)

Tube answered 31/3, 2021 at 15:3 Comment(0)
E
0

Both of these dependencies use WebRTC with them and imports org.webrtc with them, The best way I can suggest is to use Opentalk source code files (Instead of the aar dependency, if available) and use those files and use webrtc dependency that comes with the Jitsi itself. Considering you cant use Jitsi source code as its first compiled with react native dependencies.

WebRTC increases your app side drastically. You wouldn't want to import it twice anyways.

Elielia answered 31/3, 2021 at 15:10 Comment(0)
W
0

You are looking for managing the Transitive Dependencies, and the generic way to solve the clashing problem, is to exclude the transitive dependency from one of the dependencies, that brought it:

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

You can read more at dependency management of Gradle.

Wolfsbane answered 31/3, 2021 at 15:13 Comment(1)
This can be a solution but this will not work if both the dependencies are using different versions for WebRTC.Elielia
T
-1

This snap show you the problem of error : enter image description here

Tube answered 31/3, 2021 at 15:20 Comment(1)
Please describe you answers too.Marin

© 2022 - 2024 — McMap. All rights reserved.