fleeksoft / ksoup

Ksoup is a Kotlin Multiplatform library for working with HTML and XML. It's a port of the renowned Java library Jsoup.
https://fleeksoft.github.io/ksoup/
Apache License 2.0
314 stars 12 forks source link

Duplicate class com.fleeksoft.ksoup.Ksoup found in modules ksoup-release.aar #68

Open vanniktech opened 2 months ago

vanniktech commented 2 months ago

I have an application that has an implementation dependency on two modules:

When I tried to compile my application, I got:

* What went wrong:
Execution failed for task ':app-speed-reading:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class com.fleeksoft.ksoup.Ksoup found in modules ksoup-release.aar -> jetified-ksoup-release-runtime (com.fleeksoft.ksoup:ksoup-android:0.1.6) and ksoup-release.aar -> jetified-ksoup-release-runtime (com.fleeksoft.ksoup:ksoup-okio-android:0.1.6)
     Duplicate class com.fleeksoft.ksoup.Ksoup$parseFile$1 found in modules ksoup-release.aar -> jetified-ksoup-release-runtime (com.fleeksoft.ksoup:ksoup-android:0.1.6) and ksoup-release.aar -> jetified-ksoup-release-runtime (com.fleeksoft.ksoup:ksoup-okio-android:0.1.6)

Are those ksoup modules somehow modified / differently published? This should work, but it didn't. As a workaround, I just changed the textextractor module to also use the okio ksoup extension, even though it does not need okio there.

itboy87 commented 2 months ago

@vanniktech You can’t use multiple variants in a single project, as it will cause conflicts.

vanniktech commented 2 months ago

Why is that? If you think of retrofit you can also use different adapters in parallel for instance Moshi & Gson.

itboy87 commented 2 months ago

@vanniktech Actually, when I started developing it, I didn’t consider this and created a single global instance. When I created the variants, I continued using the single instance approach to keep it simple with a global Ksoup object, avoiding initialization. At that time, I didn’t anticipate this kind of issue. It’s not much to do, and I’ll address it in the next release, which should be ready by the end of next week.