Kotlin Coroutines暂停进行趣味性+改造抛出“未找到改造注释”错误 [英] Kotlin Coroutines suspend fun + retrofit throws "No Retrofit annotation found" error

查看:73
本文介绍了Kotlin Coroutines暂停进行趣味性+改造抛出“未找到改造注释”错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在2.5.1-SNAPSHOT中使用翻新程序的协程支持,但我不断收到一个奇怪的异常。

I'm trying to use retrofit's coroutine support in 2.5.1-SNAPSHOT but I keep getting a strange exception.

我的翻新服务类具有:

@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

由于天气错误,这似乎很奇怪参数#5,但只有4个参数。有人看过吗?

Which seems odd, since the error is with parameter #5, but there are only 4 parameters. Anyone seen this before?

还要注意,这是使用

minifyEnabled false

所以我怀疑这是保卫者...

So I doubt it's proguard...

推荐答案

原来,您还需要转换器工厂的SNAPSHOT版本。

Turns out you need the SNAPSHOT version of the converter factory as well.

com.squareup.retrofit2:converter-moshi:2.5.1-SNAPSHOT

这篇关于Kotlin Coroutines暂停进行趣味性+改造抛出“未找到改造注释”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆