7

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?

Borys
  • 1,793
  • 2
  • 17
  • 32

4 Answers4

8

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.

Community
  • 1
  • 1
Borys
  • 1,793
  • 2
  • 17
  • 32
4

Add these two lines to your build.gradle in the android section:

android{
    compileOptions {
            sourceCompatibility 1.8
            targetCompatibility 1.8
        }
}
Phung Duy Phong
  • 876
  • 6
  • 18
0

I double checked and I had a serialized name that was not matching with the output of the library. Problem solved!

P. Pueyo
  • 23
  • 5
0

for me it turned out that i didn't have the internet permission , the error appeared to me in logcat when i switched to an older version of retrofit , and it worked fine with me when i added the permission and switched back to the latest version. Add this permission to the manifest

    <uses-permission android:name="android.permission.INTERNET"/>
user8459720
  • 375
  • 3
  • 9