OkHttp 4 Compatibility
Closed this issue · 5 comments
I just tried this library for the first time (kotlin/JVM, version 6.0.6
) and got this error:
Exception in thread "main" java.lang.NoClassDefFoundError: okhttp3/internal/Util
at com.prof18.rssparser.internal.JvmXmlParser$parseXML$2.invokeSuspend(JvmXmlParser.kt:42)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt:42)
at com.prof18.rssparser.RssParser$getRssChannel$2.invokeSuspend(RssParser.kt:31)
at matt.scratch.ScratchMainKt$main$1.invokeSuspend(ScratchMain.kt:9)
Caused by: java.lang.NoClassDefFoundError: okhttp3/internal/Util
at com.prof18.rssparser.internal.JvmXmlParser$parseXML$2.invokeSuspend(JvmXmlParser.kt:42)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:585)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:802)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:706)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:693)
Caused by: java.lang.ClassNotFoundException: okhttp3.internal.Util
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 9 more
import com.prof18.rssparser.RssParser
import kotlinx.coroutines.runBlocking
fun main() {
runBlocking {
val channel = RssParser().getRssChannel("https://www.reddit.com/r/All/top.rss?t=week")
channel.items.forEach {
println(it.title)
}
}
}
I'm sure there is some dependency conflict.
I see only a couple of usages of the okhttp3.internal
package in here, and they don't seem like a big deal to refactor. I wonder if avoiding or writing a copy of okhttp3.internal.closeQuietly
would be enough? Maybe a quick test could determine this?
Ah, interesting, I never thought about checking okhttp4 compatibility! I will definitely look into it soon. Thanks for spotting and reporting it!
The library is already using okhttp4. I've created a new project from scratch with Intellij and added the dependencies 6.0.6
, and it's working as expected. Are you defining any other dependencies besides coroutines and RSS parser?
Anyhow, I will delete the internal usage of that method.
Yes, I am defining other dependencies. I am sure it is a dependency conflict.
If the problem persists after this change, I will take a closer look into which dependencies are causing the conflict. Hopefully removing the internal method will be enough.
I will test this as soon as it is released. Thanks!
Works perfectly now :)