Retrofit + Kotlin请求接口时遇到问题

使用Retrofit + Kotlin请求接口时,遇到问题,报错日志:java

Parameter type must not include a type variable or wildcard: java.util.Map<java.lang.String, ?> (parameter #1)

代码大体以下:api

//参数
val map : Map<String,Any> = hashMapOf(
    //添加参数
    "time" to System.CurrentTimeMillis
)
//接口定义
   @FormUrlEncoded
   @POST("api/box-mgmt")
   fun regBox(@FieldMap map:  Map<String, Any>): Observable<BaseResponseBean<Any>>

问题出在参数map的value类型Any.对于java来讲,这个value的类型是Object,能够被Retrofit识别,但对于kotlin来讲,retrofit会把Any识别成 ?,就报出了错误.
解决办法:
添加注解@JvmSuppressWildcards 日志

@FormUrlEncoded
   @POST("api/box-mgmt")
   fun regBox(@FieldMap map:  Map<String, Any>):@JvmSuppressWildcards Observable<BaseResponseBean<Any>>
相关文章
相关标签/搜索