安卓:无法更新发布版本,因为 gson 未添加例外到专业卫士



情况:

  1. 对象(.com.package.model(作为Gson字符串存储在SQLite数据库中
  2. 目前没有添加proguard异常
  3. 应用程序在play商店上发布
  4. 更新版本后,应用程序崩溃,并显示";应为开始数组,但找到字符串";错误
  5. 禁用proguard或将异常添加到两个版本都可以使错误消失由于该应用程序已经发布,有人知道我如何将旧的apk映射到新的吗?我愿意付你一杯咖啡;(

使用的异常:

# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
# For using GSON @Expose annotation
-keepattributes *Annotation*
# Gson specific classes
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { *; }

基于ProGuard为上一版本生成的映射文件,您可以使用Gson的@SerializedName手动注释模型类的字段,并使用alternate指定模糊字段名。alternate值仅在反序列化期间考虑,因此允许您通过@SerializedName注释的value指定有意义的属性名称,该名称将用于任何新序列化的数据。

最新更新