0

Using retrofit 2 and a custom Gson converter I'm getting a serialization issue at the api endpoint from a specific device (Samsung Galaxy s9). The following is my Gson config;

new Builder()
        .baseUrl(API_BASE_URL)
        .addConverterFactory(GsonConverterFactory.create(getGson()));

public static Gson getGson() {

    return new GsonBuilder()
        .setDateFormat(GSON_DATE_FORMAT)
        .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
        .registerTypeAdapter(Long.class, new LongTypeAdapter())
        .setLongSerializationPolicy( LongSerializationPolicy.STRING )
        .create();
}

Testing with a Sony Xperia premium, objects reach the api as they should, for example:

{
    client_id: '07cffbe0-6df9-4b08-a524-f19b265c17be',
    country: 'xxxx',
    email: 'xxxx',
    first_name: 'xxxx',
    last_name: 'xxxx',
    ....
}

but on a Samsung Galaxy S9 I get:

{
    a: '07cffbe0-6df9-4b08-a524-f19b265c17be',
    b: 'xxxx',
    c: 'xxxx',
    d: 'xxxx',
    e: 'xxxx',
    ....
}

Why would the serialization change on a different device?

CaptRisky
  • 751
  • 4
  • 13
  • 25

1 Answers1

1

It looks like proguard / obfuscation is enabled on one of the device and disabled on the other, are you sure that you are using the same build on both devices?

For problem with obfuscation and GSON please look here: https://stackoverflow.com/a/31851024/2879657

MDikkii
  • 273
  • 1
  • 10
  • That's it! the Samsung has the signed release version while the other is the debug version... Cheers mate lol – CaptRisky Jul 24 '19 at 14:10