问题
I'm trying to use retrofit's coroutine support in 2.5.1-SNAPSHOT but I keep getting a strange exception.
My retrofit service class has:
@GET("weather")
suspend fun getForecast(@Query("q") query: String, @Query("num_of_days") numDays: String = "1",
@Query("format") format : String = "json", @Query("key") apiKey: String = API_KEY)
: Weather
And when I try to call it I get:
2019-05-18 13:57:01.507 27422-27477/com.my.app E/MainPresenter$onResume$$inlined$CoroutineExceptionHandler: Something went wrong: No Retrofit annotation found. (parameter #5)
for method WeatherService.getForecast
Which seems odd, since the error is with parameter #5, but there are only 4 parameters. Anyone seen this before?
Also note, this is for a debug build with
minifyEnabled false
So I doubt it's proguard...
回答1:
Turns out you need the SNAPSHOT version of the converter factory as well.
com.squareup.retrofit2:converter-moshi:2.5.1-SNAPSHOT
回答2:
You need update retrofit, version > 2'6
来源:https://stackoverflow.com/questions/56201771/kotlin-coroutines-suspend-fun-retrofit-throws-no-retrofit-annotation-found-e