0
我有一个自定义列表,我正在使用Gson转换为jsonArray。Gson更改密钥
问题是,如果我使用调试版本的apk,它是完美的工作,但如果我使用发布版本apk,键会改变。
例子:
Debug version -> "name", "Mary"
Release version -> "a", "Mary"
所有按键改变为 “A,B,C ......”
我有两个版本的ProGuard。
我的代码:
Gson gson = new Gson();
JsonArray jsonArray = gson.toJsonTree(myCustomList).getAsJsonArray();
摇篮代码:
buildTypes {
release {
debuggable true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
proguard的代码:
-dontwarn okhttp3.**
-dontwarn okio.**
##---------------Begin: proguard configuration for Gson ----------
# 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.** { *; }
# Prevent proguard from stripping interface information from TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
我加入-keep class yourPackageName.data.model.** { *; }
我的包的名字,但我得到了同样的问题。
内,但我正在使用Debug版本的ProGuard太 – Dahnark
两者也真的很奇怪,我要发布的ProGuard设置 – Dahnark
这是不可能的。因为它应该重命名调试版本上的字段或方法 – santalu