Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrofit native crash Fatal signal 11 (SIGSEGV)

I'm using Retrofit library for communication with server side. From server I get list of objects

List<BaseAction>

where I store child actions as:ActionUrl, ActionBell, etc. And I got crash in callback sucсess method

 Fatal signal 11 (SIGSEGV), code 1, fault addr 0x610091 in tid 21471

And my question is: What is wrong and why retrofit crash native?

like image 260
Borys Avatar asked Jan 23 '15 13:01

Borys


1 Answers

I spend few hours for debugging and find that problem in List. Retrofit cannot correctly deserialize my JSON and convert it to java object.

In Volley I used my own class ActionDeserialize<T> implements JsonDeserializer<T> where I implement class resolving according to class:

private Type getTypeForType(BTypes bType) {
    return bType.getResponseClass();
}

More details about this here

So, I resolve my problem with setting new GsonConverter (after blog reading):

    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();

And it resolve native crash in native part. I hope it will save your time.

like image 185
Borys Avatar answered Sep 24 '22 13:09

Borys