ProGuard - org.codehaus.jackson.map.JsonMappingException: no suitable constructor found for type

I have an Android-based application that connects to Google App Engine using Rest services, the application works fine until it is confused through ProGuard before release.

Error registered in LogCat when starting a running application:

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?)

In the proguard-project.txt file, I have the following:

-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 to which the error relates looks like this:

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

To repeat before obfuscation through ProGuard, the application works fine.
Can someone help me solve this problem?

+5
source share
3 answers

Error message

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 , . , , :

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

//, .

+1

Proguard.config . .

-verbose 
-dump class_files.txt 
-printseeds seeds.txt 
-printusage unused.txt 
-printmapping mapping.txt

proguard-project.txt

:

, proguard-android-optimize.txt, proguard-android.txt.

, Android Security .

+2

, - , :

# keep anything annotated with @JsonCreator
-keepclassmembers public class * {
     @com.fasterxml.jackson.annotation.JsonCreator *;
}

, JsonCreator, , , . , , .

+1
source

All Articles