https://kotlinlang.org logo
Title
r

rattleshirt

06/13/2018, 9:58 AM
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

louiscad

06/13/2018, 10:22 AM
@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

rattleshirt

06/13/2018, 11:22 AM
Hm, am not using a crossinline lambda. Just a regular method on a view model.
All I have is:
fun refresh() = launchWithParent(dispatchers.main) {
        paymentsDataSource.refresh(Unit)
    }
with
fun launchWithParent(
        context: CoroutineContext = DefaultDispatcher,
        block: suspend CoroutineScope.() -> Unit
    ) = launch(context = context, parent = viewModelJob, block = block)
and
override suspend fun refresh(param: Unit) {
        paymentsFetcher.getPayments()
    }
I think it’s a multidex issue 😞
l

louiscad

06/13/2018, 12:38 PM
@rattleshirt On which Android version is it running, and do you use the multidex support library?
r

rattleshirt

06/13/2018, 12:39 PM
Currently running on 8.0.0 with multidex version 2.0.0
l

louiscad

06/13/2018, 12:41 PM
Weird... I'd try a clean/rebuild
r

rattleshirt

06/13/2018, 12:41 PM
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

louiscad

06/13/2018, 1:17 PM
What do you call a "submodule"?
r

rattleshirt

06/13/2018, 1:39 PM
Just a kotlin module
but multidex creates a separate
classesX.dex
file for each gradle module