使用 GSON 库导出/签名 Android 项目
我在 Android 应用程序中使用当前的 GSON 库,当应用程序构建时没有使用密钥库签名时,一切都按预期工作。
当我导出应用程序并对其进行签名时,gson 无法将 Reader 解析到我的类中。
我尝试在不使用混淆器的情况下签署应用程序,但这没有什么区别。我真的不明白为什么它在签名时表现不同。
有问题的行是这样的:
Words words = new Words();
words = gson.fromJson(r, Words.class);
当应用程序签名时,该对象只是空的。
I'm using the current GSON libraries in an android app and everything works as expected when the application is built without signing it with the keystore.
When I export the app and sign it, gson fails to parse the Reader into my class.
I've tried signing the app without using proguard but this made no difference. I'm literally lost as to why it is behaving differently when signed.
The line in question is this:
Words words = new Words();
words = gson.fromJson(r, Words.class);
The object is simply empty when the app is signed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哇,我本以为 proguard 的混淆会破坏你的模型,但我想现在 zipalign 搞砸了,为了确保你可以解析你的 json,你可以为你的模型提供特定的 gson 注释。
Wow I would have expected that the obfuscation of proguard is responsible for destroying your model, but I guess now zipalign is messing it up, to ensure that you can parse your json, you could provide specific gson annotations for your model.