Android simplexml.jar proguard问题

时间:2011-08-25 09:32:42

标签: android proguard

我只是尝试通过simple-xml-2.6.jar解析一个简单的xml文档。我把这个jar放到一个名为lib的文件夹中,然后将它添加到库中。然后我尝试跳过这个jar,以便在proguard.cfg中编写代码如下所示:

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-libraryjars lib/simple-xml-2.6.jar
-dontwarn javax.xml.stream.events.**
-dontwarn javax.xml.stream.**
-keeppackagenames  com.wang.demo
-keep public class org.simpleframework.** { *; }
-keep public class org.simpleframework.xml.core.** { *; }
-keep public class org.simpleframework.* { *; }
-keep public class org.simpleframework.xml.core.* { *; }
-keep public class org.simpleframework.* 
-keep public class org.simpleframework.xml.core.* 
-keep public class org.simpleframework.** { public protected *; }
-keep public class org.simpleframework.xml.core.** { public protected *; }
-keep public class javax.xml.** { *; }
-keepattributes *Annotation*
-dontskipnonpubliclibraryclasses
-keep public class * extends com.wang.demo.CommonResponse { *; }
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
    native <methods>;
}
-keepclasseswithmembernames class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

我想要涵盖所有异常但它显示的logcat:

08-25 17:06:56.886: WARN/System.err(8745): java.lang.NoSuchMethodException: m(dm,Element)
08-25 17:06:56.886: WARN/System.err(8745):     at java.lang.Class.getMatchingConstructor(Class.java:643)
08-25 17:06:56.886: WARN/System.err(8745):     at java.lang.Class.getConstructor(Class.java:472)
08-25 17:06:56.886: WARN/System.err(8745):     at org.simpleframework.xml.core.at.a(Unknown Source)
08-25 17:06:56.897: WARN/System.err(8745):     at org.simpleframework.xml.core.be.a(Unknown Source)
08-25 17:06:56.897: WARN/System.err(8745):     at org.simpleframework.xml.core.q.b(Unknown Source)
08-25 17:06:56.897: WARN/System.err(8745):     at org.simpleframework.xml.core.q.a(Unknown Source)
08-25 17:06:56.897: WARN/System.err(8745):     at org.simpleframework.xml.core.b.a(Unknown Source)
08-25 17:06:56.897: WARN/System.err(8745):     at org.simpleframework.xml.core.b.<init>(Unknown Source)
08-25 17:06:56.897: WARN/System.err(8745):     at org.simpleframework.xml.core.av.a(Unknown Source)
08-25 17:06:56.897: WARN/System.err(8745):     at org.simpleframework.xml.core.dn.b(Unknown Source)
08-25 17:06:56.897: WARN/System.err(8745):     at org.simpleframework.xml.core.ar.h(Unknown Source)
08-25 17:06:56.897: WARN/System.err(8745):     at org.simpleframework.xml.core.ar.g(Unknown Source)
08-25 17:06:56.897: WARN/System.err(8745):     at org.simpleframework.xml.core.ed.a(Unknown Source)
08-25 17:06:56.897: WARN/System.err(8745):     at org.simpleframework.xml.core.az.a(Unknown Source)
08-25 17:06:56.897: WARN/System.err(8745):     at org.simpleframework.xml.core.Persister.read(Unknown Source)
08-25 17:06:56.897: WARN/System.err(8745):     at org.simpleframework.xml.core.Persister.read(Unknown Source)
08-25 17:06:56.897: WARN/System.err(8745):     at org.simpleframework.xml.core.Persister.read(Unknown Source)
08-25 17:06:56.897: WARN/System.err(8745):     at org.simpleframework.xml.core.Persister.read(Unknown Source)
08-25 17:06:56.907: WARN/System.err(8745):     at org.simpleframework.xml.core.Persister.read(Unknown Source)


So anyone help me fix it?

1 个答案:

答案 0 :(得分:2)

我有同样的问题。

我认为这是因为proguard更改了Annotation属性的名称。 例如,注释属性定义为:

public @interface Attribute
{
    public String name() default "";
    public String empty() default "";
}

但是在混淆之后,它变成了:

public @interface Attribute
{
    public abstract String a();
    public abstract boolean b();
}

然后,在运行时,代码将无法通过反射获取属性名称。