AndroidAnnotations:@Rest在导出后转换Json时出错

AndroidAnnotations:@Rest在导出后转换Json时出错,rest,proguard,android-annotations,Rest,Proguard,Android Annotations,我有以下课程: public class OfferList { public List<Offer> offers; } public class Offer { public String offer_id; public String group_id; public String n_hours; public boolean is_new; } 这里称之为: (...) @RestService OfferRestServi

我有以下课程:

public class OfferList {
   public List<Offer> offers;
}

public class Offer {
    public String offer_id;
    public String group_id;
    public String n_hours;
    public boolean is_new;
}
这里称之为:

(...)
@RestService
    OfferRestService offersService;

(...)
@Background
void loadListItems() {
    mLoadingOffers = true;
    showProgressDialog();

    OfferList ol = null;
    try {
        ol = offersService.getOffers(myPrefs.userID().get(), myPrefs.lastCheckedForOffers().get());

        showDebug("ol.offers.size(): " + ol.offers.size()); //OK shows ol.offers.size(): 24

        Offer o = ol.offers.get(0); //After exporting: Crash
    showDebug("ol.offers[0].group_id" + o.group_id);

    } catch (Exception e) {
        showDebug(e.getMessage()); //After exporting shows: "com.google.gson.internal.StringMap cannot be cast to com.humihara.escolaspertodemim.Offer"
    }

    setupAdapter(ol);
    mLoadingOffers = false;
}
(...)
调试时一切正常,但当我导出并签名时,应用程序崩溃

GET被发送,来自服务器的响应是一个有效的JSON提供列表。 显然,我得到的结果是一个带有StringMap的OfferList,而不是Offer

这是我的proguard-project.txt(我使用的是android sdk默认值加上这些):

默认的android proguard定义:

-dontskipnonpubliclibraryclasses
我没有注意到他们的表情不一样

我最终得到了这个proguard-project.txt:

-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault

-dontskipnonpubliclibraryclassmembers

-keep class com.humihara.escolaspertodemim.** { *; }

-keep public class * extends android.support.v4.app.FragmentActivity

-dontwarn org.simpleframework.**
-dontnote org.simpleframework.**

-dontwarn org.codehaus.jackson.**
-dontnote org.codehaus.jackson.**

-dontwarn com.fasterxml.jackson.**
-dontnote com.fasterxml.jackson.**

-dontwarn com.google.code.rome.**
-dontnote com.google.code.rome.**

-dontwarn org.apache.commons.httpclient.**
-dontnote org.apache.commons.httpclient.**

现在一切正常。

对于使用反射访问注释的代码,您应该保留注释:

-keepattributes *Annotation*

你说得对,我没有注意到它是默认配置。星号是通配符,因此该设置包括所有与注释相关的属性。成功配置中的关键设置可能是“-keepattributes Signature”。Jackson似乎使用字段的完整通用签名来确定其内容。对于Jackson 2.1.4,我需要以下属性:
-keepattributes Signature,enclosuringmethod
-keepnames class com.fasterxml.Jackson.*{*}
-dontwarn com.fasterxml.Jackson.databind.*
-保留公共类mydatapackage.*{*;}
-dontskipnonpubliclibraryclasses
-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault

-dontskipnonpubliclibraryclassmembers

-keep class com.humihara.escolaspertodemim.** { *; }

-keep public class * extends android.support.v4.app.FragmentActivity

-dontwarn org.simpleframework.**
-dontnote org.simpleframework.**

-dontwarn org.codehaus.jackson.**
-dontnote org.codehaus.jackson.**

-dontwarn com.fasterxml.jackson.**
-dontnote com.fasterxml.jackson.**

-dontwarn com.google.code.rome.**
-dontnote com.google.code.rome.**

-dontwarn org.apache.commons.httpclient.**
-dontnote org.apache.commons.httpclient.**
-keepattributes *Annotation*