错误使用Proguard的杰克逊库后模糊处理工作 [英] Error working with Jackson library post-obfuscation using Proguard

查看:225
本文介绍了错误使用Proguard的杰克逊库后模糊处理工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过各种查询与使用Proguard的问题瓦特/混淆冲刷后,我来,我觉得我可能是的只有的是具有这一具体问题的地步。因此,在后。

after scouring through all sorts of queries related to issues w/ obfuscation using Proguard, I've come to the point where I feel I might be the only one having this particular issue. Hence, the post.

我有一个相当标准的Andr​​oid应用程序,它利用了基于JSON的REST调用交换数据。我利用杰克逊库解析JSON数据。一切都已经可以完美地运行,直到我们决定将模糊处理为我们的发布版本使用Proguard的。整理出回调有关问题的世界后,我终于坚持了有关杰克逊库中的一个问题。

I have a fairly standard android app which makes use of JSON-based REST calls to exchange data. I make use of the Jackson library to parse the JSON data. Everything had been working flawlessly, until we decided to incorporate obfuscation for our release builds using Proguard. After sorting out a world of callback related problems, I'm finally stuck with a problem related to the Jackson library.

基本上,该行 ObjectMapper OM =新ObjectMapper() - 是行不通的!我不断收到以下错误在该行:

basically, the line ObjectMapper om = new ObjectMapper() - just doesn't work! I keep getting the following error at that line:

Caused by: java.lang.ExceptionInInitializerError
    at org.codehaus.jackson.map.ObjectMapper.<clinit>(Unknown Source)
    ... 8 more
Caused by: java.lang.NullPointerException
    at org.codehaus.jackson.map.introspect.VisibilityChecker$Std.<init>(Unknown Source)
    at org.codehaus.jackson.map.introspect.VisibilityChecker$Std.<clinit>(Unknown Source)
    ... 9 more

阅读了许多相关的,包括外部库的其他职位,使得ProGuard的无视杰克逊库类,开启和关闭的优化和收缩标志后,我只是无能的现在。

After reading a host of other posts related to including external libraries, making proguard ignore the Jackson library classes, turning on and off optimization and shrinking flags, I'm just clueless right now.

我已经包含在我的 proguard.cfg 文件杰克逊的缘故各种各样的东西 -

The various things I've included in my proguard.cfg file for Jackson's sake -

-dontskipnonpubliclibraryclassmembers
-dontoptimize
-dontshrink
-libraryjars xtraLibs/joda-time-1.6.2.jar;xtraLibs/xml-apis.jar;xtraLibs/jsr311-api-0.8.jar;xtraLibs/stax2-api-3.0.0.jar;xtraLibs/httpmime-4.0.1.jar

在这些,我已经切换了 dontoptimize dontshrink 标志。但是,结果始终是相同的。

amongst these, I've toggled the dontoptimize and dontshrink flags. However, the result has always been the same.

在所有我在试图解决这一问题所花的时间,我来感到惊讶,并已经进入Proguard的库中的那种努力敬畏。只是,当事情不工作,他们有点的混淆的。

In all the time I've spent in trying to solve this issue, I've come to be amazed and awed by the kind of effort gone into the Proguard library. It's just that when things don't work, they're a bit obfuscated.

Proguard的版本 - 4.6

Proguard version - 4.6

推荐答案

这不是从堆栈跟踪显而易见的,但杰克逊需要一些注释,其中的ProGuard删除默认。 (CFR)。 ProGuard的手动>例子> 处理注释的:

It's not obvious from the stack trace, but Jackson needs some annotations, which ProGuard removes by default. Cfr. ProGuard manual > Examples > Processing annotations:

-keepattributes *Annotation*,EnclosingMethod

此外,作为不祥的包名'组织。codehaus.jackson.map.introspect表明,杰克逊进行的分析类自省找到getter和setter。不知道任何好转,ProGuard的可删除或重命名这些,因为你的code可能不会使用它们显式。您可能必须让他们明确的,例如:

Furthermore, as the ominous package name 'org.codehaus.jackson.map.introspect' suggests, Jackson performs introspection on parsed classes to find getters and setters. Without knowing any better, ProGuard may be removing or renaming these, because your code might not use them explictly. You may have to keep them explicitly, e.g.:

-keep public class mydatapackage.** {
  public void set*(***);
  public *** get*();
} 

这篇关于错误使用Proguard的杰克逊库后模糊处理工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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