Android minifyEnabled true和shrinkResources true在版本构建改型api中';他们不工作了
这是我的proguard文件:Android minifyEnabled true和shrinkResources true在版本构建改型api中';他们不工作了,android,proguard,minify,shrink,release-builds,Android,Proguard,Minify,Shrink,Release Builds,这是我的proguard文件: -keepattributes *Annotation* -keepattributes SourceFile,LineNumberTable -keep public class * extends java.lang.Exception -printmapping mapping.txt -keepattributes Signature, InnerClasses, EnclosingMethod -keepattributes RuntimeVis
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
-printmapping mapping.txt
-keepattributes Signature, InnerClasses, EnclosingMethod
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
-keepclassmembers,allowshrinking,allowobfuscation interface * {
@retrofit2.http.* <methods>;
}
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn javax.annotation.**
-dontwarn kotlin.Unit
-dontwarn retrofit2.KotlinExtensions
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
-dontwarn org.codehaus.mojo.animal_sniffer.*
-dontwarn okhttp3.internal.platform.ConscryptPlatform
-keepattributes Signature
-keepattributes Annotation
-dontwarn sun.misc.**
-keep class com.google.gson.examples.android.model.** { <fields>; }
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
我还添加了一个屏幕截图,显示我正在调用api。
在调试构建过程中,一切正常。我只在发布版本中遇到问题。
我已经为我的模型使用了serializedName。
在过去的两天里,从stackoverflow尝试了这么多答案。
如果有人有任何想法,请告诉我。查看您的映射文件f.i.d.b.c.c.a所指的内容,如果它指的是Model/Pojo,那么您必须处理GSON的proguard规则,或者您也可以在Model类的顶部添加
@Keep
。我对发布版本有同样的问题,并且发布调试变体工作正常。
以下是一个错误:
.z.i.a.a.b(:33)
at kotlinx.coroutines.v0.run(:241)
at kotlinx.coroutines.w2.a.a(:594)
at kotlinx.coroutines.w2.a.a(:60)
at kotlinx.coroutines.w2.a$b.run(:740)
只需在下面添加渐变:
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'
通过此链接在proguard文件中添加以下内容:
查看映射文件并搜索类f.j.c.z.h,它将显示真实姓名尝试将@SerializeName添加到服务响应正文的字段中我已经添加了@SerializeName。@DeepakRajput您可以在这里添加您的proguard作为答案吗?答案不是pro guard,而是模型类的@keep anotation。如何检查映射文件?我不知道你能给我一些链接什么的。目前我没有任何链接作为参考,但您可以在映射文件中逐个搜索字符,如first find f,然后查找f.i的含义。在映射文件中,每个类/变量/方法都有一个引用/别名,如:com.android.example.launchect$Presenter Presenter->cYour编写的解决方案保持工作。但在每一个模型上都写上“保持”难道不好吗。
.z.i.a.a.b(:33)
at kotlinx.coroutines.v0.run(:241)
at kotlinx.coroutines.w2.a.a(:594)
at kotlinx.coroutines.w2.a.a(:60)
at kotlinx.coroutines.w2.a$b.run(:740)
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'