我正在使用retofit2的以下依赖关系进行xml和gson解析。
编译'com.squareup.retrofit2:converter-simplexml:2.1.0'
编译'com.squareup.retrofit2:converter-gson:2.1.0'
一切正常,数据解析正确在调试和发布apk。但是当我使用minifyEnabled = true和shrinkResources = true释放apk时,xml解析不再起作用了。 Gson也引起了问题,并通过将SerializedName注释应用于Model的每个属性来解决,因为proguard在生成apk时重命名属性,导致解析问题。
我如何解决xml解析问题?我想要使用minifyEnabled。 以下命令来自Progurad Rules File。
-keepattributes SourceFile,LineNumberTable
-renamesourcefileattribute SourceFile
-dontwarn org.codehaus.mojo.animal_sniffer.**
-dontwarn java.nio.file.**
# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on RoboVM on iOS. Will not be used at runtime.
-dontnote retrofit2.Platform$IOS$MainThreadExecutor
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions
-dontwarn javax.xml.stream.**
# SimpleXMLParsing
-keep public class org.simpleframework.** { *; }
-keep class org.simpleframework.xml.** { *; }
-keep class org.simpleframework.xml.core.** { *; }
-keep class org.simpleframework.xml.util.** { *; }
-keepattributes ElementList, Root
-keepclassmembers class * {
@org.simpleframework.xml.* *;
}
-dontwarn jp.co.cyberagent.android.gpuimage.**