如何设置ProGuard的杰克逊JSON处理器? [英] How to setup PROGUARD for Jackson JSON Processor?

查看:184
本文介绍了如何设置ProGuard的杰克逊JSON处理器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的杰克逊JSON处理器为我的这个使用app.Included

I am using Jackson JSON Processor for my app.Included this using

compile 'com.fasterxml.jackson.core:jackson-databind:2.4.2'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.2'.

和我ProGuard的配置。

And my proguard configuration is.

## BEGIN -- Google Play Services proguard.txt
-keep class * extends java.util.ListResourceBundle {
    protected java.lang.Object[][] getContents();
}
# Keep SafeParcelable value, needed for reflection. This is required to support backwards
# compatibility of some classes.
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}
# Keep the names of classes/members we need for client functionality.
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}
# Needed for Parcelable/SafeParcelable Creators to not get stripped
-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}
## END -- Google Play Services proguard.txt

-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault

-dontskipnonpubliclibraryclassmembers
-dontskipnonpubliclibraryclasses
-keepattributes *Annotation*.
-keep class org.codehaus.jackson.**




-dontwarn twitter4j.**
-dontwarn com.facebook.android.BuildConfig
-dontwarn org.apache.commons.**
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**
-dontwarn com.nhaarman.listviewanimations.**

然而,当我尝试在调试模式下编译我碰到下面的错误。

However when i try to compile in debug mode i get the following error.

26207-26207/com.blah E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.blah, PID: 26207
    java.lang.NoSuchFieldError: PUBLIC_ONLY
            at java.lang.Class.getDeclaredAnnotation(Native Method)
            at java.lang.Class.getAnnotation(Class.java:290)
            at com.b.a.c.f.ah.<clinit>(Unknown Source)
            at com.b.a.c.z.<clinit>(Unknown Source)
            at com.blah.utils.c.<init>(Unknown Source)
            at com.blah.main.a.a(Unknown Source)
            at com.blah.main.b.a.a(Unknown Source)
            at com.blah.main.b.a.onCreateView(Unknown Source)

做这个工作,很长一段时间!请问AP preciate你的帮助!谢谢!

Working on it for a long time!Would appreciate your help!Thanks!

推荐答案

经过多次调试终于找到了答案,我ProGuard的配置是

After much debugging finally found the answer my proguard configuration is

-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 depicts the getter setter classes/class your are using to parse your response.

此外,我加入编译com.fasterxml.jackson.core:杰克逊核心:2.4.2 我的摇篮文件,该文件是缺少previously.Now我ProGuard的作品就像一个野兽..; - )

Also i added compile 'com.fasterxml.jackson.core:jackson-core:2.4.2' to my gradle file which was missing previously.Now my proguard works like a beast..;-)

这篇关于如何设置ProGuard的杰克逊JSON处理器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆