Retrofit @ java.lang.IllegalArgumentException:@FieldMap键必须是字符串类型:K(参数#2)
问题描述:
此例外只出现在一部手机中,而其他手机正常。我应该如何解决这个问题?这个异常与proguard有关吗?Retrofit @ java.lang.IllegalArgumentException:@FieldMap键必须是字符串类型:K(参数#2)
详细例外:
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)
答
由于没有代码片段,我建议你向你的服务方法的签名更改从@FieldMap HashMap/Map params
到@FieldMap HashMap<String, String> params
。并称它是这样的
HashMap<String, String> params = ServiceUtil.getInstance().getDefaultParams();
maisService.fetchAjudaCategorias(params)
这应该很好。