【发布时间】:2019-10-05 16:37:20
【问题描述】:
我正在尝试在 2.5.1-SNAPSHOT 中使用改造的协程支持,但我不断收到一个奇怪的异常。
我的改造服务类有:
@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...
【问题讨论】:
-
我没有解决方案,但问题是因为 Kotlin 编译器将您的方法更改为采用额外的参数,用于协程继续。
-
我已经解决了,并发布了解决方案。谢谢
标签: android kotlin retrofit coroutine