Retrofit @ java.lang.IllegalArgumentException:@FieldMap键必须是String类型:K(参数#2)

时间:2017-02-15 09:12:27

标签: retrofit okhttp

此异常仅发生在一部手机中,而其他手机没问题。我该怎么解决这个问题?这个例外与proguard有关吗?

详情异常:

java.lang.IllegalArgumentException: @FieldMap keys must be of type String: K (parameter #2)
for method g.d
at retrofit2.ServiceMethod$Builder.methodError(Unknown Source)
at retrofit2.ServiceMethod$Builder.methodError(Unknown Source)
at retrofit2.ServiceMethod$Builder.parameterError(Unknown Source)
at retrofit2.ServiceMethod$Builder.parseParameterAnnotation(Unknown Source)
at retrofit2.ServiceMethod$Builder.parseParameter(Unknown Source)
at retrofit2.ServiceMethod$Builder.build(Unknown Source)
at retrofit2.Retrofit.loadServiceMethod(Unknown Source)
at retrofit2.Retrofit$1.invoke(Unknown Source)
at $Proxy0.d(Native Method)

1 个答案:

答案 0 :(得分:0)

如果没有代码段,我建议您将服务方法签名从@FieldMap HashMap/Map params更改为@FieldMap HashMap<String, String> params。并称之为

HashMap<String, String> params = ServiceUtil.getInstance().getDefaultParams();
                                maisService.fetchAjudaCategorias(params)

这应该可以正常工作。