。ProGuard的 - 组织codehaus.jackson.map.JsonMappingException:找到了类型没有合适的构造 [英] ProGuard - org.codehaus.jackson.map.JsonMappingException: No suitable constructor found for type

查看:313
本文介绍了。ProGuard的 - 组织codehaus.jackson.map.JsonMappingException:找到了类型没有合适的构造的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有被连接到谷歌应用程序引擎使用REST服务,基于Android的应用程序,该应用程序完美的作品,直到它通过ProGuard混淆在发布之前。

I have an Android-based application which is connecting to the Google App Engine using Rest services, the app works perfectly until it is obfuscated through ProGuard prior to release.

运行混淆应用程序时报告的LogCat中的错误是:

The error reported in LogCat when running the obfuscated app is:

Unable to convert a [application/json,UTF-8] representation into an object of 
  class com.enterprisemk.android.bcw.bincollection.WasteCollectionAreasContainer

org.codehaus.jackson.map.JsonMappingException: No suitable constructor found 
  for type [simple type, class 
  com.enterprisemk.android.bcw.bincollection.WasteCollectionAreasContainer]: 
  can not instantiate from JSON object (need to add/enable type information?)

我在我的ProGuard-project.txt文件如下:

I have the following in my proguard-project.txt file:

-keepattributes *Annotation*,EnclosingMethod

-keep public class org.w3c.** {public private protected *;}
-dontwarn org.w3c.**

-keep public class org.joda.time.** {public private protected *;}
-dontwarn org.joda.time.**

-keep public class org.restlet.** { *; }
-dontwarn org.restlet.**

-keep public class org.codehaus.** { *; }
-dontwarn org.codehaus.**

-keepattributes Signature
-keepnames class com.fasterxml.jackson.** { *; }
-dontwarn com.fasterxml.jackson.databind.**

和班里的错误指的是如下:

And my class the error refers to looks like:

public class WasteCollectionAreasContainer {

 public List<WasteCollectionAreas> wasteCollectionAreasList;

 public List<WasteCollectionAreas> getWasteCollectionAreasList() {
     return wasteCollectionAreasList;
 }

 public void setWasteCollectionAreasist(List<WasteCollectionAreas> wasteCollectionAreasList) {
     this.wasteCollectionAreasList = wasteCollectionAreasList;
 }

 public WasteCollectionAreasContainer() {
     wasteCollectionAreasList = new ArrayList<WasteCollectionAreas>();
 }

 @JsonCreator
 public WasteCollectionAreasContainer(List<WasteCollectionAreas> wasteCollectionAreasList) {
     this.wasteCollectionAreasList = wasteCollectionAreasList;
 }
}

要通过ProGuard的于模糊处理应用程序完美的作品前重申。结果
谁能帮我解决这个问题?

To reiterate prior to obfuscation through ProGuard the app works perfectly.
Can anyone help me solve this problem?

推荐答案

错误消息

org.codehaus.jackson.map.JsonMappingException: No suitable constructor found for type
    [simple type, class com.enterprisemk.android.bcw.bincollection.WasteCollectionAreasContainer]:
    can not instantiate from JSON object (need to add/enable type information?)

表明杰克逊库尝试反序列化使用反射类,其原有的名称和注释的构造函数。 ProGuard的无法预见这一点,所以它可能已删除或重命名类及其构造函数。你可能需要preserve他们明确的:

suggests that the Jackson library is trying to deserialize your class using reflection, with its original name and its annotated constructor. ProGuard can't foresee this, so it may have removed or renamed the class and its constructor. You probably need to preserve them explicitly:

-keep class com.enterprisemk.android.bcw.bincollection.WasteCollectionAreasContainer {
    <init>(java.util.List);
}

有可能有其他类似的类/场/需要是出于同样的原因preserved方法

There may be other similar classes/fields/methods that need to be preserved for the same reasons.

这篇关于。ProGuard的 - 组织codehaus.jackson.map.JsonMappingException:找到了类型没有合适的构造的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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