Exclude transitive dependencies from JAR

Hi, I have a third-party SDK in the form of JAR file, after adding the JAR file to my project as below
stagingImplementation(name: “SDK name”, ext: “jar”)
it pulls in other dependencies already included in the app causing duplicate class errors, stacktrace provided below

Duplicate class com.google.common.annotations.Beta found in modules guava-31.1-android.jar -> jetified-guava-31.1-android (com.google.guava:guava:31.1-android) and sdk-14.1.1.jar -> jetified-sdk-14.1.1 (:sdk-14.1.1:)

how can I exclude the transitive dependencies from the JAR file?

You provide too less information to give any meaningful advice.
If that is a bad-practice fat jar (repackaging all dependencies inside the jar) you cannot exclude them except maybe by using an artifact transform.
If it is just a normal JAR with dependencies coming from a Maven repository or similar, there should be proper conflict resolution and thus no duplicate classes, so excluding transitive dependencies should not be necessary, but if really needed you could configure the dependency to be non-transitive and so only include the jar itself.
If you have to live with such a bad-practice fat jar and know which dependencies are repackaged into it, you could exclude the dependencies that are already packed into that jar from the configuration.

Hi @Vampire
Thank you for your response, I have edited the question to provide more details. please elaborate your response
“there should be proper conflict resolution” should this be on SDK side or on my project side?

Ah, Android.
Android is always special in most regards and I’m not really into Android development.

But as far as I remember other people posting such problems,
the output usually contains a hyperlink to a page in the Android documentation
that explains how to deal with such duplicate class problems in Android projects.