在 build.gradle
中 minifyEnabled true 之后像下面的
buildTypes {
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
当我在 minifyEnabled为true 时进行api调用时,我获得了成功,但是一些参数值更改与期望值不同。
还有
当我调用api时,而** minifyEnabled为false **,我得到了来自后端的实际值。
(即)我在api响应中获得了 isValidUser 参数,该参数是布尔值 实际值为isValidUser = true,这是预期值,但我得到了isValidUser = false。
请帮助我我的build.gradle文件是什么问题?
答案 0 :(得分:1)
@ Arbaz.in,如果您使用@SerializedName并保留Gson,则您无需保留课程,尽管在极少数情况下,您需要同时进行 您可以为您的GSON使用以下proguard规则,该规则应起作用: GSON Proguard
答案 1 :(得分:0)
在 Payam Kokabi 的帮助下,
问题已解决 minifyEnabled true 是在我们声明时不会更改值
-keep class YOUR CLASS ** { *; }
在您的 proguard-rules.pro 文件中。
答案 2 :(得分:0)
请确切指定哪些部分不起作用,但通常应将其从模型中指定出来,因此应将其排除在规则文件中,如下所示:
# Models
-keepclassmembers class com.example.models.** {*;}
# GSON
-keepattributes Signature
-keepattributes *Annotation*
-dontwarn sun.misc.**
-keep class com.google.gson.examples.android.model.** { *; }
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer