hey, I've got a problem: I'm trying to use Retrofi...
# android
l
hey, I've got a problem: I'm trying to use Retrofit with the Kotlin Coroutine-integration (just make the functions in the
API
interface
suspend
and return the data directly, without being wrapped in
Call
) but as soon as i try to do this, i get
java.lang.IllegalArgumentException: Could not locate call adapter for class java.lang.Object.
any ideas? if i use the
Call
wrapped way it works
d
Make sure you're using retrofit 2.6.0+
As it wasn't added until then I believe
g
Could you show declaration of this Retrofit method
CallAdapter is not needed for Coroutines and suspend functions, now it's part of core Retrofit
d
Oh you're right - my mistake!
u
@gildor why is that? what if I only want to use rx
g
why is that
I didn’t get your question. Retrofit supports suspend functions out of the box now, no need to have any adapters. Rx requires adapter
d
I think he means he shouldnt have to take the coroutines dependency if he is using rx
g
No, suspend function is part of Kotlin itself and stdlib, it has nothing to do with kotlinx.coroutines. And because Retrofit is written now in Kotlin you anyway have dependency on Kotlin stdlib
d
kotlinx.coroutines is an optional dependency of retrofit
g
Yes, it’s optional, to support cancellation and provide
Call.await()