嗨我的发布版本有问题,我使用proguard。在调试中一切正常。 当我试着打电话时: validator.validate(); 他们扔了:
java.lang.NoSuchFieldError
at libcore.reflect.AnnotationAccess.decodeValue(AnnotationAccess.java:688)
at libcore.reflect.AnnotationAccess.toAnnotationInstance(AnnotationAccess.java:663)
at libcore.reflect.AnnotationAccess.annotationSetToAnnotations(AnnotationAccess.java:633)
at libcore.reflect.AnnotationAccess.getDeclaredAnnotations(AnnotationAccess.java:161)
at java.lang.reflect.Field.getDeclaredAnnotations(Field.java:234)
at java.lang.reflect.AccessibleObject.getAnnotations(AccessibleObject.java:104)
at com.mobsandgeeks.saripaar.Validator.getViewFieldsWithAnnotations(SourceFile:478)
at com.mobsandgeeks.saripaar.Validator.getSaripaarAnnotatedFields(SourceFile:453)
at com.mobsandgeeks.saripaar.Validator.validateAllRules(SourceFile:346)
at com.mobsandgeeks.saripaar.Validator.validate(SourceFile:156)
at pl.someclass.fragment.RegistrationFragment$1.onClick(SourceFile:92)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.NoSuchFieldException: LONG
at java.lang.Class.getDeclaredField(Class.java:886)
at libcore.reflect.AnnotationAccess.decodeValue(AnnotationAccess.java:685)
... 20 more
java.lang.NoSuchFieldException: LONG
at java.lang.Class.getDeclaredField(Class.java:886)
at libcore.reflect.AnnotationAccess.decodeValue(AnnotationAccess.java:685)
at libcore.reflect.AnnotationAccess.toAnnotationInstance(AnnotationAccess.java:663)
at libcore.reflect.AnnotationAccess.annotationSetToAnnotations(AnnotationAccess.java:633)
at libcore.reflect.AnnotationAccess.getDeclaredAnnotations(AnnotationAccess.java:161)
at java.lang.reflect.Field.getDeclaredAnnotations(Field.java:234)
at java.lang.reflect.AccessibleObject.getAnnotations(AccessibleObject.java:104)
at com.mobsandgeeks.saripaar.Validator.getViewFieldsWithAnnotations(SourceFile:478)
at com.mobsandgeeks.saripaar.Validator.getSaripaarAnnotatedFields(SourceFile:453)
at com.mobsandgeeks.saripaar.Validator.validateAllRules(SourceFile:346)
at com.mobsandgeeks.saripaar.Validator.validate(SourceFile:156)
at pl.someclass.fragment.RegistrationFragment$1.onClick(SourceFile:92)
还有其他人有过类似的问题吗?
这是我的proguard-rules.pro文件:
-dontwarn javax.management.**
-dontwarn java.lang.management.**
-dontwarn javax.xml.**
-dontwarn org.apache.**
-dontwarn org.slf4j.**
-keep class com.facebook.** { *; }
-keepattributes Signature
-dontwarn com.google.code.**
-dontwarn oauth.signpost.**
-keep class twitter4j.** { *; }
#javamail
-dontwarn java.awt.**
-dontwarn java.beans.Beans
-dontwarn javax.security.**
-keep class javamail.** {*;}
-keep class javax.mail.** {*;}
-keep class javax.activation.** {*;}
-keep class com.sun.mail.dsn.** {*;}
-keep class com.sun.mail.handlers.** {*;}
-keep class com.sun.mail.smtp.** {*;}
-keep class com.sun.mail.util.** {*;}
-keep class mailcap.** {*;}
-keep class mimetypes.** {*;}
-keep class myjava.awt.datatransfer.** {*;}
-keep class org.apache.harmony.awt.** {*;}
-keep class org.apache.harmony.misc.** {*;}
-dontshrink
-keep class myjava.** {*;}
-keep class org.apache.harmony.** {*;}
-keep public class Mail {*;}
#acra
#ACRA specifics
# Restore some Source file names and restore approximate line numbers in the stack traces,
# otherwise the stack traces are pretty useless
-keepattributes SourceFile,LineNumberTable
# ACRA needs "annotations" so add this...
# Note: This may already be defined in the default "proguard-android-optimize.txt"
# file in the SDK. If it is, then you don't need to duplicate it. See your
# "project.properties" file to get the path to the default "proguard-android-optimize.txt".
-keepattributes *Annotation*
# keep this class so that logging will show 'ACRA' and not a obfuscated name like 'a'.
# Note: if you are removing log messages elsewhere in this file then this isn't necessary
-keep class org.acra.ACRA {
*;
}
# keep this around for some enums that ACRA needs
-keep class org.acra.ReportingInteractionMode {
*;
}
-keepnames class org.acra.sender.HttpSender$** {
*;
}
-keepnames class org.acra.ReportField {
*;
}
# keep this otherwise it is removed by ProGuard
-keep public class org.acra.ErrorReporter{
public void addCustomData(java.lang.String,java.lang.String);
public void putCustomData(java.lang.String,java.lang.String);
public void removeCustomData(java.lang.String);
}
# keep this otherwise it is removed by ProGuard
-keep public class org.acra.ErrorReporter{
public void handleSilentException(java.lang.Throwable);
}
答案 0 :(得分:0)
通过在proguard-rules.pro
文件中添加以下行,从混淆中排除Saripaar类。
-keep class com.mobsandgeeks.saripaar.** {*;}