googlesamples / googlesamples/mlkit
genai-prompt 1.0.0-beta4: NoSuchMethodError at runtime with kotlinx-coroutines 1.10.x – POM omits the required >= 1.11.0 constraint
- Dominant language
- Kotlin
- Stars
- 4.3k
- Forks
- 3.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Description
`com.google.mlkit:genai-prompt:1.0.0-beta4` crashes at runtime with a `NoSuchMethodError` when the app's dependency graph resolves kotlinx-coroutines 1.10.x. The library's bytecode requires coroutines >= 1.11.0, but its published POM does not declare that requirement, so Gradle happily resolves older versions and the failure only appears on device.
### Minimal reproduction
https://github.com/adrianczuczka/mlkit-genai-coroutines-repro – clone, run, tap the button. The app declares `genai-prompt:1.0.0-beta4` plus `kotlinx-coroutines-android:1.10.2` (a current, valid version) and calls `GenerativeModel.download()`.
### Observed
```
java.lang.NoSuchMethodError: No static method cancel$default(Lkotlinx/coroutines/Job;Ljava/util/concurrent/CancellationException;ILjava/lang/Object;)V in class Lkotlinx/coroutines/Job; or its super classes
at com.google.android.gms.internal.mlkit_genai_prompt.zzyl.invoke(com.google.mlkit:genai-prompt@@1.0.0-beta4:1)
at kotlinx.coroutines.channels.ProduceKt.awaitClose(Produce.kt:69)
at kotlinx.coroutines.channels.ProduceKt$awaitClose$1.invokeSuspend(Produce.kt:13)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:232)
```
Observed on a Pixel 10 Pro XL (Android 17) inside the `download()` flow; the failure is class linkage, not AICore behavior.
### Root cause
kotlinx-coroutines switched interface compilation to `-Xjvm-default=all` in 1.11.0. Verified with `javap -p` against both published jars:
| | `Job.cancel$default` (interface static) | `Job$DefaultImpls.cancel$default` |
|---|---|---|
| coroutines 1.10.2 | absent | present |
| coroutines 1.11.0 | present | present (compat) |
genai-prompt 1.0.0-beta4 was compiled against >= 1.11.0 and its bytecode invokes the interface-static form, which does not exist on a 1.10.x runtime classpath.
### Expected
The published POM (or Gradle module metadata) declares the real minimum:
```xml
org.jetbrains.kotlinx
kotlinx-coroutines-core
1.11.0
```
so dependency resolution upgrades automatically instead of crashing at runtime.
### Workaround
Pin `kotlinx-coroutines-android:1.11.0` (or newer) in the app.
Contributor guide
No contributing guide indexed for this repository
Research direction
Clone the linked minimal reproduction, run it, and inspect the published genai-prompt 1.0.0-beta4 POM or Gradle module metadata. Compare its declared kotlinx-coroutines requirement with the bytecode evidence in the issue. Done means dependency resolution selects 1.11.0 or newer and the download() flow no longer reaches the reported NoSuchMethodError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- build-system, mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100