我只是试着用simple-xml-2.6.jar解析一个简单的xml文档。我把这个jar放到一个名为lib的文件夹中,然后把它添加到libraries中。然后我尝试跳过proguard.cfg中的jar so代码,如下所示:
-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?
我也有同样的问题。
我认为这是因为proguard
更改了Annotation
属性的名称。例如,注释属性被定义为:
public @interface Attribute
{
public String name() default "";
public String empty() default "";
}
但是经过混淆之后,它变成了:
public @interface Attribute
{
public abstract String a();
public abstract boolean b();
}
那么,在运行时,代码将无法通过反射获取属性名。