Proguard obfuscation is breaking simplexml

后端 未结 7 818
耶瑟儿~
耶瑟儿~ 2020-12-14 18:01

I am using simplexml in my android project, and everything works fine until I obfuscate the code. Then, errors start pouring in.

Part of the XML is as follows:

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-14 18:21

    I kept getting the following errors:

    can't find referenced class javax.xml.stream.XMLEventReader

    can't find referenced class javax.xml.stream.events.XMLEvent

    This is because these are part of the Java runtime (rt.jar) but not part of the Android runtime (android.jar), so ProGuard warns that something might be broken. This isn't actually a problem, so we can do the following:

    -dontwarn javax.xml.stream.events.**
    

    Source

    Combined with the answer of zmicer, I get the following

    -dontwarn javax.xml.stream.events.**
    
    -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.* *;
    }
    

提交回复
热议问题