gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:47:41 27 4
gpt4 key购买 nike

我有一个基于 Android 的应用程序,它使用 Rest 服务连接到 Google App Engine,该应用程序运行完美,直到它在发布之前通过 ProGuard 进行了混淆处理。

运行混淆后的应用程序时,LogCat报错为:

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 文件中有以下内容:

-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.**

我的类(class)错误指的是:

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 进行混淆之前,该应用程序运行完美。
谁能帮我解决这个问题?

最佳答案

将以下内容添加到您的 Proguard.config。它将帮助您定位问题。

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

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

我认为您应该使用 proguard-android-optimize.txt,而不是 proguard-android.txt

为了完整起见,感谢 Riley Hassell Android Security Discussions的技巧。

关于android - ProGuard - org.codehaus.jackson.map.JsonMappingException : No suitable constructor found for type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15794027/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com