Add Proguard for Jackson JSON Processor
goonerDroid opened this issue · 8 comments
Hey guys do you have any ideas for implementation of Jackson JSON Processor.Would appreciate if you guys included it!
@goonerDroid good point. I do actually have configuration for that in one of my projects, I'll add it to the library.
@krschultz hey added the config but i get the following crash.
E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.crap, PID: 10579
java.lang.NoSuchFieldError: PUBLIC_ONLY
at java.lang.Class.getDeclaredAnnotation(Native Method)
at java.lang.Class.getAnnotation(Class.java:290)
at com.fasterxml.jackson.databind.f.ai.(Unknown Source)
at com.fasterxml.jackson.databind.ObjectMapper.(Unknown Source)
at com.crap.utils.c.(Unknown Source)
at com.crap.main.d.a(Unknown Source)
at com.crap.main.b.a.a(Unknown Source)
at com.crap.main.b.a.onCreateView(Unknown Source)
at android.app.Fragment.performCreateView(Fragment.java:1700)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
at android.app.BackStackRecord.run(BackStackRecord.java:684)
Also i added the following to the proguard config:-
-dontwarn org.w3c.dom.bootstrap.DOMImplementationRegistry
Try disabling obfuscation in the proguard-project.pro file and see if it works. Obviously you wouldn't want that permanently, but I want to see if that fixes it. I'm pulling the Jackson config from a project with obfuscation turned off.
-dontobfuscate
@krschultz Finally found my proguard config for Jackson Proccessor.My Config is as follows:-
-keepattributes Annotation,EnclosingMethod,Signature
-keepnames class com.fasterxml.jackson.* { ; }
-dontwarn com.fasterxml.jackson.databind.
-keep class org.codehaus.* { ; }
-keepclassmembers public final enum org.codehaus.jackson.annotate.JsonAutoDetect$Visibility {
public static final org.codehaus.jackson.annotate.JsonAutoDetect$Visibility *; }
-keep public class your.class.* {
public void set_(_);
public ** get*();
}
your.class here is the getter/setter you are using to parse the response
also keep in mind to compile the same versions of Jackson Library.In my case i am using
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.2'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.2'
compile 'com.fasterxml.jackson.core:jackson-core:2.4.2'
-keepnames class com.fasterxml.jackson.** { ; }
-dontwarn com.fasterxml.jackson.databind.
Just add this and add in gradle this.
you need to add * in bracket{ } before semicolon
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.3'
compile 'com.fasterxml.jackson.core:jackson-core:2.5.3'
it will work definitely.
Dunno why @krschultz reopened this issue rules posted by me is working fine!
@goonerDroid I dropped the ball on this. I reopened it at the time because although you posted the config here, we never actually put it into a file in the libraries folder. This is what we currently have:
# Proguard configuration for Jackson 2.x (fasterxml package instead of codehaus package)
-keep class com.fasterxml.jackson.databind.ObjectMapper {
public <methods>;
protected <methods>;
}
-keep class com.fasterxml.jackson.databind.ObjectWriter {
public ** writeValueAsString(**);
}
@goonerDroid work fine for me
thanks