我正在尝试在 2.5.1-SNAPSHOT 中使用 retrofit 的协程支持,但我不断收到一个奇怪的异常。
我的改造服务类有:
@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
当我尝试调用它时,我得到:
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
这看起来很奇怪,因为错误与参数 #5 有关,但只有 4 个参数。有人见过这个吗?
另请注意,这是用于调试构建的
minifyEnabled false
所以我怀疑它是proguard...
最佳答案
事实证明您还需要转换器工厂的 SNAPSHOT 版本。
com.squareup.retrofit2:converter-moshi:2.5.1-SNAPSHOT
关于android - Kotlin Coroutines suspend fun + retrofit throws "No Retrofit annotation found"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56201771/