Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Dependencies of an Android plugin for Unity collide with the dependencies downloaded by unity-jar-re

Discussion in 'Android' started by Virtumonde, Mar 27, 2021.

  1. Virtumonde

    Virtumonde

    Joined:
    Apr 15, 2020
    Posts:
    84
    There is this situation where I am trying to use MLKit inside Unity. Naturally I make an Android plugin. Here are the Gradle dependencies:

    dependencies {
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

    implementation "androidx.camera:camera-camera2:1.1.0-alpha02"
    implementation "com.google.mlkit:pose-detection:17.0.1-beta3"
    }


    Then I compile the .aar using

    task copyPlugin(type: Copy) {
    dependsOn assemble
    from ('build/outputs/aar')
    into ('../../../Assets/Plugins/Android')
    include (project.name + '-release.aar')
    }


    What happens next is that Unity is not able to access androidx.camera:camera-camera2:1.1.0-alpha02 or com.google.mlkitpose-detection:17.0.1-beta3. Because of this, I have to use unity-jar-resolver to download the dependencies so that Unity will link them with the resulting app. I expected everything will work but now the dependencies seem to collide. Can you give me an insight into this? Here is the Unity build error:


    * What went wrong:
    Execution failed for task ':launcher:checkDebugDuplicateClasses'.
    > 1 exception was raised by workers:
    java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class androidx.camera.camera2.Camera2Config found in modules PoseDetector-release-runtime.jar (:PoseDetector-release:) and androidx.camera.camera-camera2-1.1.0-alpha02-runtime.jar (:androidx.camera.camera-camera2-1.1.0-alpha02:)
    Duplicate class androidx.camera.camera2.Camera2Config$DefaultProvider found in modules PoseDetector-release-runtime.jar (:PoseDetector-release:) and androidx.camera.camera-camera2-1.1.0-alpha02-runtime.jar (:androidx.camera.camera-camera2-1.1.0-alpha02:)
    Duplicate class androidx.camera.camera2.impl.Camera2CameraCaptureResultConverter found in modules PoseDetector-release-runtime.jar (:PoseDetector-release:) and androidx.camera.camera-camera2-1.1.0-alpha02-runtime.jar (:androidx.camera.camera-camera2-1.1.0-alpha02:)
     
  2. Virtumonde

    Virtumonde

    Joined:
    Apr 15, 2020
    Posts:
    84