簡體   English   中英

Kotlin 協程暫停 fun + 改造拋出“No Retrofit annotation found”錯誤

[英]Kotlin Coroutines suspend fun + retrofit throws "No Retrofit annotation found" error

我正在嘗試在 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...

事實證明,您還需要轉換器工廠的 SNAPSHOT 版本。

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

您需要更新改造,版本 > 2'6

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM