mediapipe
mediapipe copied to clipboard
Duplicate Class Error in MediaPipe library with SDK 34
I am encountering a Duplicate Class Error when trying to integrate MediaPipe Vision SDK with SDK 34 in my project. After adding the dependency:
implementation("com.google.mediapipe:tasks-vision:0.10.14")
The project syncs successfully, but when I try to run it, I get the following duplicate class errors:
Please help resolve this conflict or provide guidance on how to resolve this dependency issue.
I have one suggestion: please update all MediaPipe Android samples to support SDK 34 or 35 to ensure compatibility with newer Android versions.
I have the same issue at the moment
I spent many days on resolving this issue to be able to use both FaceMesh and HandLandmarks API from Mediapipe. For anyone who is still facing this issue, here is the tool which resolved the problem for me on my Android Library.
https://github.com/devinmorgan/shadow-plugin-for-aar/tree/main
Just try to use the example from this repo, and relocate all those dependencies from one of the mediapipe modules that are causing such duplicate. Like this:
extensions.getByType(ShadowAarDependenciesPluginExtension::class.java).apply {
relocations.set(mutableListOf(
listOf("com.google.mediapipe.formats.annotation.proto", "com.example.com.google.mediapipe.formats.annotation.proto"),
listOf("com.google.mediapipe.formats.proto", "com.example.com.google.mediapipe.formats.proto"),
listOf("com.google.mediapipe.framework", "com.example.com.google.mediapipe.framework"),
listOf("com.google.mediapipe.proto", "com.example.com.google.mediapipe.proto"),
listOf("com.google.mediapipe.util.proto", "com.example.com.google.mediapipe.util.proto")
))
}
dependencies {
implementation(libs.mediapipe.face.mesh)
add("aarImplementation", libs.mediapipe.tasks.vision)
}
Like above, add all the namespaces which has this Duplicate issue. Please notice the different way of adding one dependency from the other. One is added with the regular implementation and the other with add("aarImplementation", name.of.the.other.mediapipe.dependency)
This way, you can relocate the packages from one of the modules to a different namespace and use them in your project if needed.