Retrofit 2 在发布版 APK 中在 minifyenable 时返回 null 但在调试 APK 中正常 [英] Retrofit 2 returns null in release APK when minifyenable but ok in debug APK

查看:35
本文介绍了Retrofit 2 在发布版 APK 中在 minifyenable 时返回 null 但在调试 APK 中正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在启用缩小时获得空响应但代码为 200 并带有 Release APK,当缩小为 false 时就可以了.

Getting null response but code 200 with Release APK when minify enable, when minify false then its ok.

但是在启用缩小时使用调试 APK 获得预期响应.

But Getting expected response with debug APK when minify enable.

推荐答案

问题已解决 :)

proguard-rules 没有问题,无需添加任何额外内容.

No issue with proguard-rules no need to add anything extra.

即使变量名与key相同,如果minifyEnabled,也需要添加SerializedName注解.

Needed to add SerializedName annotation if minifyEnabled even if variable name same as key.

那是我手动创建的唯一模型:P

That was the only Model which i had created manually :P

在调试中可以正常工作,但在登录后不行.:)

Which works fine in Debug but not after Signed in. :)

这篇关于Retrofit 2 在发布版 APK 中在 minifyenable 时返回 null 但在调试 APK 中正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆