java.lang.NoSuchMethodError: kotlinx.coroutines.SupervisorKt.SupervisorJob
See original GitHub issueTrying to use runBlockingTest
for my unit tests, and getting the above-mentioned error.
Here are my code snippets:
@Test
fun `test verify test call`() = runBlockingTest {
registerViewModel.testCall()
verify(repo).suspendedTestCall()
}
fun testCall() {
viewModelScope.launch(Dispatchers.IO) {
repository.suspendedTestCall()
}
}
suspend fun suspendedTestCall() {
kotlinx.coroutines.delay(2_000)
}
Also getting the same error when trying to use TestCoroutineDispatcher.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:17 (6 by maintainers)
Top Results From Across the Web
kotlin, coroutines, NoSuchMethodError when calling ...
It fails with exception: java.lang.NoSuchMethodError: com.example.lib.OtherModuleInterface.test(Lkotlin/coroutines/experimental/Continuation;) ...
Read more >Gradle plugin with ktor client (java.lang.NoSuchMethodError
Gradle plugin with ktor client (java.lang.NoSuchMethodError: kotlinx.coroutines). Hi, I ve got this error. Plugin com.browserstack.gradle loaded Extension ...
Read more >SupervisorKt
Creates a new supervisor job object in an active state. ... Function2<? super kotlinx.coroutines. ... Continuation<? super R>,? extends java.lang.
Read more >platform/external/kotlinx.coroutines
+ * [CoroutineScope](https://kotlin.github.io/kotlinx.coroutines/kotlinx- ... kotlinx/coroutines/SupervisorKt { + public static final fun SupervisorJob ...
Read more >limitedParallelism
Creates a view of the current dispatcher that limits the parallelism to the given value. The resulting view uses the original dispatcher for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Does your version of
kotlinx-coroutines-test
matches with the version ofkotlinx-coroutines-core
?The problem here is not in the library itself but in transitive dependencies.
How to verify you have this problem
In Android Studio or IntelliJ IDEA press
Find symbol
hotkey (cmd/ctrl+ N) and typekotlinx.coroutines.Job
. If you see more than two versions of the class (example), it’s a dependency clash.How to resolve the problem
You have multiple options here:
kotlinx-coroutines-core
(additionally tokotlinx-coroutines-android
orkotlinx-coroutines-test
or any other kx-coroutines dependency) with the desired version to your dependencieskotlinx.coroutines
explicitly using custom Gradle resolution strategy@JakubMosakowski thanks for the reproducer!