使用 GSON 库导出/签名 Android 项目

发布于 2025-01-01 10:32:48 字数 309 浏览 3 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暗藏城府 2025-01-08 10:32:48

哇,我本以为 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文