ragunathjawahar / android-saripaar

UI form validation library for Android
Apache License 2.0
3.22k stars 460 forks source link

Proguard issue #45

Closed AresM closed 9 years ago

AresM commented 9 years ago

Hi i have problem with my release version where I use proguard. In debug everything works fine. When I try to Call: validator.validate(); they throw: 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)

Has anyone else had a similar problem?

ragunathjawahar commented 9 years ago

@AresM thank you for reporting this.

ragunathjawahar commented 9 years ago

Can you please let me know the device model and the Android version running on the device?

AresM commented 9 years ago

Android 5.0 Nexus 5 and Android: 4.4.4 Manufacturer: samsung Model: SM-G357FZ

AresM commented 9 years ago

That my proguard-rules.pro file:

-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); }

AresM commented 9 years ago

Do You have any solution for this issue?

ragunathjawahar commented 9 years ago

As a temporary fix try adding this to your proguard configuration file. -keep class com.mobsandgeeks.saripaar.** {*;}

Let me know how it goes.

AresM commented 9 years ago

Thanks now it works fine.