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

App Crashes when upgrading to Ksoup 0.1.6 #69

Closed Vaibhav2002 closed 2 months ago

Vaibhav2002 commented 2 months ago

Describe the bug I was using 0.1.2 before and now as soon as I upgrade to 0.1.6 app Crashes

The ktor version I am using in my project is 2.3.12 If I downgrade Ksoup back to 0.1.2 everything works like normal, but as soon as I upgrade to 0.1.6 and make the dependency changes

- ksoup = { module = "com.fleeksoft.ksoup:ksoup", version.ref="ksoup" }
- ksoup-network = { module = "com.fleeksoft.ksoup:ksoup-network", version.ref = "ksoup" }

+ ksoup = { module = "com.fleeksoft.ksoup:ksoup-ktor2", version.ref="ksoup" }
+ ksoup-network = { module = "com.fleeksoft.ksoup:ksoup-network-ktor2", version.ref = "ksoup" }
java.lang.NoClassDefFoundError: Failed resolution of: Lio/ktor/client/plugins/HttpTimeout; (Ask Gemini)
    at com.medial.app.data.network.client.ApiClientKt.setUpTimeout(ApiClient.kt:44)
    at com.medial.app.data.network.client.ApiClientKt.getApiClient$lambda$8(ApiClient.kt:85)
    at com.medial.app.data.network.client.ApiClientKt.$r8$lambda$TZZ_TpM4akCT0yjXLLzSEwyjaH0(Unknown Source:0)
    at com.medial.app.data.network.client.ApiClientKt$$ExternalSyntheticLambda6.invoke(Unknown Source:4)
    at io.ktor.client.HttpClientKt.HttpClient(HttpClient.kt:42)
    at io.ktor.client.HttpClientJvmKt.HttpClient(HttpClientJvm.kt:23)
    at com.medial.app.data.network.client.ApiClientKt.getApiClient(ApiClient.kt:80)
    at com.medial.app.data.network.di.NetworkModuleKt.networkModule$lambda$20$lambda$0(NetworkModule.kt:30)
    at com.medial.app.data.network.di.NetworkModuleKt.$r8$lambda$syS4-sq_LbTId_GUlTQaYwzuxe0(Unknown Source:0)
    at com.medial.app.data.network.di.NetworkModuleKt$$ExternalSyntheticLambda0.invoke(Unknown Source:4)
    at org.koin.core.instance.InstanceFactory.create(InstanceFactory.kt:50)
    at org.koin.core.instance.SingleInstanceFactory.create(SingleInstanceFactory.kt:46)
    at org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SingleInstanceFactory.kt:55)
    at org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SingleInstanceFactory.kt:53)
    at org.koin.mp.KoinPlatformTools.synchronized(KoinPlatformTools.kt:36)
    at org.koin.core.instance.SingleInstanceFactory.get(SingleInstanceFactory.kt:53)
    at org.koin.core.registry.InstanceRegistry.resolveInstance$koin_core(InstanceRegistry.kt:109)
    at org.koin.core.scope.Scope.resolveValue(Scope.kt:247)
    at org.koin.core.scope.Scope.resolveInstance(Scope.kt:233)
    at org.koin.core.scope.Scope.get(Scope.kt:212)
    at com.medial.app.data.network.di.NetworkModuleKt$networkModule$lambda$20$$inlined$singleOf$default$5.invoke(SingleOf.kt:227)
    at com.medial.app.data.network.di.NetworkModuleKt$networkModule$lambda$20$$inlined$singleOf$default$5.invoke(SingleOf.kt:52)
    at org.koin.core.instance.InstanceFactory.create(InstanceFactory.kt:50)
    at org.koin.core.instance.SingleInstanceFactory.create(SingleInstanceFactory.kt:46)
    at org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SingleInstanceFactory.kt:55)
    at org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SingleInstanceFactory.kt:53)
    at org.koin.mp.KoinPlatformTools.synchronized(KoinPlatformTools.kt:36)
    at org.koin.core.instance.SingleInstanceFactory.get(SingleInstanceFactory.kt:53)
    at org.koin.core.registry.InstanceRegistry.resolveInstance$koin_core(InstanceRegistry.kt:109)
    at org.koin.core.scope.Scope.resolveValue(Scope.kt:247)
    at org.koin.core.scope.Scope.resolveInstance(Scope.kt:233)
    at org.koin.core.scope.Scope.get(Scope.kt:212)
    at com.medial.app.data.di.DataModuleKt$dataModule$lambda$18$$inlined$singleOf$default$5.invoke(SingleOf.kt:227)
    at com.medial.app.data.di.DataModuleKt$dataModule$lambda$18$$inlined$singleOf$default$5.invoke(SingleOf.kt:68)
    at org.koin.core.instance.InstanceFactory.create(InstanceFactory.kt:50)
    at org.koin.core.instance.SingleInstanceFactory.create(SingleInstanceFactory.kt:46)
    at org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SingleInstanceFactory.kt:55)
    at org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SingleInstanceFactory.kt:53)
    at org.koin.mp.KoinPlatformTools.synchronized(KoinPlatformTools.kt:36)
    at org.koin.core.instance.SingleInstanceFactory.get(SingleInstanceFactory.kt:53)
    at org.koin.core.registry.InstanceRegistry.resolveInstance$koin_core(InstanceRegistry.kt:109)
    at org.koin.core.scope.Scope.resolveValue(Scope.kt:247)
    at org.koin.core.scope.Scope.resolveInstance(Scope.kt:233)
    at org.koin.core.scope.Scope.get(Scope.kt:212)
    at com.medial.app.ui.navigation.RootComponentImpl.<init>(RootComponent.kt:491)
    at com.medial.app.MedialApp_androidKt.setUpMedialApp$lambda$1(MedialApp.android.kt:24)
    at com.medial.app.MedialApp_androidKt.$r8$lambda$e-YieZpbZl1DHSupQWleEJCt0E4(Unknown Source:0)
    at com.medial.app.MedialApp_androidKt$$ExternalSyntheticLambda0.invoke(Unknown Source:6) (Ask Gemini)
    at com.arkivanov.decompose.RetainedComponentHolder.<init>(RetainedComponent.kt:187)
    at com.arkivanov.decompose.RetainedComponentKt.retainedComponent(RetainedComponent.kt:110)
    at com.arkivanov.decompose.RetainedComponentKt.retainedComponent(RetainedComponent.kt:52)
    at com.arkivanov.decompose.RetainedComponentKt.retainedComponent$default(RetainedComponent.kt:45)
    at com.medial.app.MedialApp_androidKt.setUpMedialApp(MedialApp.android.kt:21)
    at com.medial.app.MedialApp_androidKt.setUpMedialApp$default(MedialApp.android.kt:13)
    at com.medial.android.ui.MainActivity.onCreate(MainActivity.kt:60)
    at android.app.Activity.performCreate(Activity.java:8595)
    at android.app.Activity.performCreate(Activity.java:8573)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3764)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3922)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:205)
    at android.os.Looper.loop(Looper.java:294)
    at android.app.ActivityThread.main(ActivityThread.java:8177)

                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Caused by: java.lang.ClassNotFoundException: Didn't find class "io.ktor.client.plugins.HttpTimeout" on path: DexPathList[[zip file "/data/app/~~7FClsFDKOM7XxWjKpj3PdQ==/com.med
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    ... 71 more

To Reproduce Steps to reproduce the behavior: Upgrade to 0.1.6

Expected behavior App should work fine

itboy87 commented 2 months ago

I think your project has a dependency that uses Ktor 3, and Gradle is resolving it to Ktor 3 or a different version. Can you please check the dependency graph to see which version of Ktor it is using? If Ktor 3 is already being used in your project, you can use Ksoup with Ktor 3.

itboy87 commented 2 months ago

@Vaibhav2002 Hi there! I just wanted to check in and see if you had a chance to look into the dependency graph and confirm the Ktor version. Please let me know if you need any assistance with this or if you’ve encountered any further issues. I’m happy to help!

Vaibhav2002 commented 2 months ago

@itboy87 let me check the dependency graph, will let you know

Vaibhav2002 commented 2 months ago

@itboy87 I just checked the dependency graph and I dont see Ktor 3.x anywhere I only see Ktor 2.3.12

itboy87 commented 2 months ago

@Vaibhav2002 Can you share the code if possible, or at least the dependencies you’re using?

Vaibhav2002 commented 2 months ago

This is my versions catalogue

I noticed that as soon as I upgrade Ksoup, i can see Ktor 3.0.0-beta2 in dependency graph, but its not there before upgrading

agp = "8.2.0"
kotlin = "2.0.0"
ktor = "2.3.12"
compose = "1.6.10"
multiplatform-settings = "1.1.1"
koin = "3.5.3"
stately = "2.0.4"
sql-delight = "2.0.1"
buildKonfig = "0.15.1"
coil = "3.0.0-alpha10"
decompose="3.0.0"
ksoup = "0.1.6"
compass = "1.0.0"
connectivity = "1.1.2"
kmpalette = "3.1.0"

[libraries]

#utils
coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version = "1.8.0" }
kotlinx-dateTime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version = "0.5.0" }
napier = { module = "io.github.aakira:napier", version = "2.6.1" }
touchlabs-crashlytics = { module = "co.touchlab.crashkios:crashlytics", version = "0.8.5" }

ksoup = { module = "com.fleeksoft.ksoup:ksoup-ktor2", version.ref="ksoup" }
ksoup-network = { module = "com.fleeksoft.ksoup:ksoup-network-ktor2", version.ref = "ksoup" }

kotlinx-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.6.2"}
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
rebugger = { module = "io.github.theapache64:rebugger", version = "1.0.0-rc02"}
kotlinx-immutable-collections = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version = "0.3.7"}
fileKit = { module = "io.github.vinceglb:filekit-core", version = "0.7.0" }
inAppReview = { module = "io.github.sergeimikhailovskii:in-app-review-kmp-google-play", version = "3.1.21" }

connectivity-device = { module = "dev.jordond.connectivity:connectivity-device", version.ref = "connectivity" }
connectivity-device-compose = { module = "dev.jordond.connectivity:connectivity-compose-device", version.ref = "connectivity" }

compass-geocoder = { module = "dev.jordond.compass:geocoder", version.ref = "compass" }
compass-geocoder-mobile = { module = "dev.jordond.compass:geocoder-mobile", version.ref = "compass" }
compass-geolocation = { module = "dev.jordond.compass:geolocation", version.ref = "compass" }
compass-geolocation-mobile = { module = "dev.jordond.compass:geolocation-mobile", version.ref = "compass" }

#paging
androidx-paging = { module = "androidx.paging:paging-common", version = "3.3.0-alpha02"}
paging-compose-common = { module = "app.cash.paging:paging-compose-common", version = "3.3.0-alpha02-0.4.0" }

#ui
kevinnzou-webview = { group = "io.github.kevinnzou", name = "compose-webview-multiplatform", version = "1.9.12" }
compottie = { module = "io.github.alexzhirkevich:compottie", version = "2.0.0-beta02" }
compose-dnd = { module = "com.mohamedrejeb.dnd:compose-dnd", version = "0.1.0"}
peekaboo-image-picker = { module = "io.github.onseok:peekaboo-image-picker", version = "0.5.2" }
zoomable = { module = "com.mxalbert.zoomable:zoomable", version = "1.6.1" }
constraintLayout = { module = "tech.annexflow.compose:constraintlayout-compose-multiplatform", version = "0.4.0" }
kmpalette-core = { module = "com.kmpalette:kmpalette-core", version.ref = "kmpalette" }
kmpalette-extensions-network = { module = "com.kmpalette:extensions-network", version.ref = "kmpalette" }

#image-loading
coil = { module = "io.coil-kt.coil3:coil", version.ref = "coil"}
coil-network = { module = "io.coil-kt.coil3:coil-network-ktor2", version.ref = "coil" }
coil-compose = { module = "io.coil-kt.coil3:coil-compose", version.ref = "coil"}
coil-svg = { module = "io.coil-kt.coil3:coil-svg", version.ref = "coil"}
coil-gif = { module = "io.coil-kt.coil3:coil-gif", version.ref = "coil" }

#moko
moko-permissions = { module = "dev.icerock.moko:permissions-compose", version = "0.17.0" }

#decompose
decompose-core = { module = "com.arkivanov.decompose:decompose", version.ref = "decompose"}
decompose-compose = { module = "com.arkivanov.decompose:extensions-compose", version.ref = "decompose"}

#workaround for iOS issue
stately-isolate = { module = "co.touchlab:stately-isolate", version.ref = "stately" }
stately-iso-collections = { module = "co.touchlab:stately-iso-collections", version.ref = "stately" }

#DI
koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" }
koin-android = { module = "io.insert-koin:koin-android", version.ref = "koin" }

#ktor
ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
ktor-client-darwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktor" }
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }

#sqldelight
sqlDelight-runtime = { module = "app.cash.sqldelight:runtime", version.ref = "sql-delight" }
sqlDelight-coroutines-ext = { module = "app.cash.sqldelight:coroutines-extensions", version.ref = "sql-delight" }
sqlDelight-paging3-ext = { module = "app.cash.sqldelight:androidx-paging3-extensions", version.ref = "sql-delight" }
sqlDelight-primitive-adapters = { module = "app.cash.sqldelight:primitive-adapters", version.ref = "sql-delight" }
sqlDelight-android-driver = { module = "app.cash.sqldelight:android-driver", version.ref = "sql-delight" }
sqlDelight-native-driver = { module = "app.cash.sqldelight:native-driver", version.ref = "sql-delight" }

#multiplatform settings
multiplatform-settings = { module = "com.russhwolf:multiplatform-settings", version.ref = "multiplatform-settings" }
multiplatform-settings-coroutines = { module = "com.russhwolf:multiplatform-settings-coroutines", version.ref = "multiplatform-settings" }
multiplatform-settings-datastore = { module = "com.russhwolf:multiplatform-settings-datastore", version.ref = "multiplatform-settings" }

# for conventions
android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "agp" }
kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
compose-compiler-gradlePlugin = { group = "org.jetbrains.kotlin", name = "compose-compiler-gradle-plugin", version.ref = "kotlin" }
compose-gradlePlugin = { module = "org.jetbrains.compose:org.jetbrains.compose.gradle.plugin", version.ref = "compose" }
itboy87 commented 2 months ago

@Vaibhav2002 thanks! I will check it with those dependencies. Can you tell me which library in the dependency graph is relying on Ktor 3? Is it Ksoup?

Vaibhav2002 commented 2 months ago

Yes Ksoup as well as all my modules which uses Ktor are now showing this

io.ktor:ktor-client-core:2.3.12 -> 3.0.0-beta-2

Before upgrade, everywhere Ktor was shown like this in all my modules

io.ktor:ktor-client-core:2.3.12
itboy87 commented 2 months ago

@Vaibhav2002   I found the issue in the library. Thanks for reporting it. I will fix it and publish a quick version 0.1.7 today.

itboy87 commented 2 months ago

@Vaibhav2002 I have released new version 0.1.7 and this issue has been fixed in it. Could you please check?. Thanks

Vaibhav2002 commented 2 months ago

@itboy87 It's working now, thanks