Anyone else ran into this: `java.lang.NoSuchMethod...
# coroutines
r
Anyone else ran into this:
java.lang.NoSuchMethodError: No virtual method refresh(Lkotlin/Unit;Lkotlin/coroutines/experimental/Continuation;)Ljava/lang/Object;
when calling a suspend fun with param
Unit
? Is this a coroutine or dex’ing issue?
l
@rattleshirt I recall having this, when launching a coroutine from a crossinline lambda. I fixed it by moving the code to a member function that I called from the crossinlin lambda
r
Hm, am not using a crossinline lambda. Just a regular method on a view model.
All I have is:
Copy code
fun refresh() = launchWithParent(dispatchers.main) {
        paymentsDataSource.refresh(Unit)
    }
with
Copy code
fun launchWithParent(
        context: CoroutineContext = DefaultDispatcher,
        block: suspend CoroutineScope.() -> Unit
    ) = launch(context = context, parent = viewModelJob, block = block)
and
Copy code
override suspend fun refresh(param: Unit) {
        paymentsFetcher.getPayments()
    }
I think it’s a multidex issue 😞
l
@rattleshirt On which Android version is it running, and do you use the multidex support library?
r
Currently running on 8.0.0 with multidex version 2.0.0
l
Weird... I'd try a clean/rebuild
r
Tried that 😞
Trying to keep the class in the main dex file
I moved the class from the submodule into the app source and now it is working
l
What do you call a "submodule"?
r
Just a kotlin module
but multidex creates a separate
classesX.dex
file for each gradle module