Koog crashes with NoSuchMethodError after kotlinx-datetime 0.7.1
In a Kotlin/Android project using Koog (JetBrains/koog), adding kotlinx-datetime 0.7.1 causes
java.lang.NoSuchMethodErroronAnthropicLLMClient/OpenAILLMClientconstructors, orClassNotFoundException: kotlinx.datetime.Clock$Systemat build time. Why does Koog conflict with kotlinx-datetime 0.7.x, and what dependency works around it?Originally asked on GitHub: https://github.com/JetBrains/koog/issues/725
5 answers
This issue was closed as completed, but the thread does not name the exact Koog release containing the fix. The root cause is that Koog was compiled against kotlinx-datetime's
Clocktype. In kotlinx-datetime 0.7.0+, that type became a deprecated typealias tokotlin.time.Clock, so the old method signatures Koog calls no longer exist. That produces errors like:java.lang.NoSuchMethodError: No direct method <init>(...Lkotlin/time/Clock;...)V in class ...AnthropicLLMClient ... java.lang.ClassNotFoundException: kotlinx.datetime.Clock$SystemOne commenter suggested using the compatibility artifact until Koog ships an update:
ktsimplementation("org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.7.1-0.6.x-compat")That artifact is meant to keep both the older API Koog still calls and the newer 0.7.1 API, but nobody in the thread confirmed it works. Another reporter found that Koog 0.4.1 worked while 0.4.2 failed in the same setup, so pinning Koog to 0.4.1 may also avoid the error. A contributor linked JetBrains YouTrack issue KG-544 to track the dependency upgrade.
Did this work for you?What @PranavPurwar tried on GitHub (Outcome unclear)
Proposed using
org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.7.1-0.6.x-compatas a dependency to keep compatibility with both Koog's API and kotlinx-datetime 0.7.1. No one in the thread confirmed it worked.Source: https://github.com/JetBrains/koog/issues/725#issuecomment-3314608708 (opens external site)
Did this work for you?What @ai-hwj tried on GitHub (Didn't work)
Reporter using Koog 0.4.2 with a custom executor and kotlinx-datetime 0.6.2 hit
NoSuchMethodErroronOpenAILLMClient; they stated Koog 0.4.1 succeeded in the same setup.Source: https://github.com/JetBrains/koog/issues/725#issuecomment-3295662932 (opens external site)
Did this work for you?What @geomagilles tried on GitHub (Didn't work)
Adding kotlinx-datetime 0.7.1 to a project failed the build with
java.lang.ClassNotFoundException: kotlinx.datetime.Clock$System.Source: https://github.com/JetBrains/koog/issues/725#issuecomment-3304355689 (opens external site)
Did this work for you?What a GitHub user tried on GitHub (Outcome unclear)
Issue body requested upgrading kotlinx-datetime from 0.6.2 to 0.7.1 for better
kotlin.time.Instant/Clockcompatibility; no concrete attempt was described.Source: https://github.com/JetBrains/koog/issues/725 (opens external site)
Did this work for you?
Related questions
- Does koog support local LLMs on Android or iOS?
- Does koog support iOS targets in Kotlin Multiplatform projects?
- Koog: can I use tool calls with executeStreaming?
- Does Koog support the A2A Protocol for multi-agent systems?
- koog executeStreaming() missing tools arg: tool calls dropped in streaming responses