这很奇怪,但序列化在DEBUG构建模式以及除一个之外的所有API响应中都完美无缺。但是在发布模式下,它会抛出非法的参数异常。
以下是此例外的完整日志:
FATAL EXCEPTION: main Process: com.example.sampleapp, PID: 30480 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sampleapp/com.example.sampleapp.activity.ManageStoreActivity}: java.lang.IllegalArgumentException: Unable to create converter for class com.example.sampleapp.model.seller.SellerStoreFormData
for method ApiInterface.getSellerInfoData
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.IllegalArgumentException: Unable to create converter for class com.example.sampleapp.model.seller.SellerStoreFormData
for method ApiInterface.getSellerInfoData
at retrofit2.ServiceMethod$Builder.methodError(Unknown Source)
at retrofit2.ServiceMethod$Builder.createResponseConverter(Unknown Source)
at retrofit2.ServiceMethod$Builder.build(Unknown Source)
at retrofit2.Retrofit.loadServiceMethod(Unknown Source)
at retrofit2.Retrofit$1.invoke(Unknown Source)
at java.lang.reflect.Proxy.invoke(Proxy.java:393)
at $Proxy0.getSellerInfoData(Unknown Source)
at com.example.sampleapp.connection.a.i(Unknown Source)
at com.example.sampleapp.activity.ManageStoreActivity.onStart(Unknown Source)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1237)
at android.app.Activity.performStart(Activity.java:6253)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
... 9 more
Caused by: java.lang.IllegalArgumentException: class com.example.sampleapp.model.seller.SellerStoreFormData declares multiple JSON fields named f
at com.google.a.b.a.i.a(Unknown Source)
at com.google.a.b.a.i.a(Unknown Source)
at com.google.a.e.a(Unknown Source)
at retrofit2.converter.gson.GsonConverterFactory.responseBodyConverter(Unknown Source)
at retrofit2.Retrofit.nextResponseBodyConverter(Unknown Source)
at retrofit2.Retrofit.responseBodyConverter(Unknown Source)
... 20 more
到目前为止我尝试了什么?
我也在发布模式下启用了proguard。
之前工作正常(没有启用proguard),我没有得到任何编译时错误。
答案 0 :(得分:4)
如果调试模式正在运行并且释放是问题,那么大多数机会都是一个问题。 尝试从混淆中排除SellerStoreFormData。
另外,检查您是否有proguard Gson configuration,如果没有,请添加。