android - Kotlin Coroutines suspend fun + retrofit throws "No Retrofit annotation found"错误

标签 android kotlin retrofit coroutine

我正在尝试在 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/

相关文章:

android - 如何在android中的相对布局内将每个布局设置在另一个布局下方

java - availableProcessors() 为双核手机返回 1

安卓工作室 2.0 : Why does Instant Run not work when modifying xml layout resources?

java - 如何从 Firestore 查询中排除元素?

java - 如何在 WearOS 应用上直接访问互联网

java - Vert.x 使用 BLOB 和 hibernate 对来自数据库的数据进行分块回答

android - 使用 Retrofit 解析数组内的动态数组

android - 如何摆脱过度滚动发光

java - 如何从json中获取列表列表?

android - 带过滤器的环回android sdk REST api