当我通过android studio调试时,我的应用程序运行良好。 但是当我构建为apk然后安装在设备上时,它不起作用。
在调试时,服务器api运行良好,但是从json转换为java对象时发生了错误(我使用gson)。 问题是代码在调试模式下可以正常运行(从android studio构建并运行),但通过apk安装时失败。 有人在这里遇到过同样的错误吗?
// API调用
getUserPrivateInfo().map(res -> {
MZDebug.d("UserPrivateInfo", res.toString());
CommonCheck.checkResponse(res);
return res.getData();
});
//然后出错:仅由apk安装的应用
java.lang.NullPointerException: throw with null exception
答案 0 :(得分:1)
在我看来,这与 Proguard 配置
有关为避免此问题,请在Proguard文件中添加新规则
-keep class path of your data class.** { *; }