改造本机崩溃致命信号11(SIGSEGV)

Bor*_*rys 5 serialization android json gson retrofit

我正在使用Retrofit库与服务器端进行通信.从服务器我得到对象列表

List<BaseAction>
Run Code Online (Sandbox Code Playgroud)

我将子操作存储为:ActionUrl, ActionBell, etc. 我在回调成功方法中崩溃了

 Fatal signal 11 (SIGSEGV), code 1, fault addr 0x610091 in tid 21471
Run Code Online (Sandbox Code Playgroud)

我的问题是:出了什么问题以及为什么改装崩溃本机?

Bor*_*rys 8

我花了几个小时进行调试,并在List中找到该问题.Retrofit无法正确反序列化我的JSON并将其转换为java对象.

在Volley中我使用了自己的类ActionDeserialize<T> implements JsonDeserializer<T>,我根据类实现了类解析:

private Type getTypeForType(BTypes bType) {
    return bType.getResponseClass();
}
Run Code Online (Sandbox Code Playgroud)

关于这里的更多细节

所以,我通过设置新的GsonConverter解决了我的问题(在博客阅读之后):

    Gson gson = new GsonBuilder()
            .registerTypeAdapter(BaseActionPOJO.class, new ActionDeserialize<BaseActionPOJO>())
            .create();

    RestAdapter restAdapter = new RestAdapter.Builder()
            .setLogLevel(loglevel)
            .setConverter(new GsonConverter(gson))
            .setRequestInterceptor(requestInterceptor)
            .setEndpoint(Urls.BASE_URL)
            .setClient(new OkClient())
            .build();
Run Code Online (Sandbox Code Playgroud)

它解决了原生部分的本机崩溃问题.我希望它能节省你的时间.