question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.NoSuchMethodError: kotlinx.coroutines.SupervisorKt.SupervisorJob

See original GitHub issue

Trying 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
elizarovcommented, Aug 16, 2019

Does your version of kotlinx-coroutines-test matches with the version of kotlinx-coroutines-core?

2reactions
qwwdfsadcommented, Aug 20, 2019

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 type kotlinx.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:

  1. Check whether dependencies that rely on coroutines can be updated and update them, if so
  2. Explicitly add kotlinx-coroutines-core (additionally to kotlinx-coroutines-android or kotlinx-coroutines-test or any other kx-coroutines dependency) with the desired version to your dependencies
  3. Resolve to the desired version of kotlinx.coroutines explicitly using custom Gradle resolution strategy

@JakubMosakowski thanks for the reproducer!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found