Jackson mapper throws “conflicting setter definitions” on Samsung SM-T580

Problem: When converting JSON to an object with Jackson, the following exception is thrown on my Samsung SM-T580 (Android 6.0.1). The exception is not thrown on a OnePlus3 (Android 6.0.1) or ZenPad 8.0 (Android 5), only on the Samsung SM-T580.

java.lang.IllegalArgumentException: Conflicting setter definitions for property "myanmarEncoding": android.graphics.Paint#setMyanmarEncoding(1 params) vs android.graphics.Paint#setMyanmarEncoding(1 params)
           at [Source: N/A; line: -1, column: -1]

The mapping is performed like the following (Jackson version 2.8.4).

import com.fasterxml.jackson.databind.ObjectMapper;
ObjectMapper objectMapper = new ObjectMapper();
try {
    myObj = objectMapper.convertValue(document.getProperties(), MyClass.class);
} catch (Exception e) {
    Log.e(TAG, e.getLocalizedMessage());

Approach: First, I’ve added @JsonIgnoreProperties(ignoreUnknown = true) to MyClass. Then, I’ve attempted to work around the issue by using @JsonIgnoreType on the android.graphics.Paint class via mix in. This was kind of successful because it prevents the first exception.

Unfortunately, another exception is thrown:

java.lang.IllegalArgumentException: Conflicting setter definitions for property "content": android.widget.HoverPopupWindow#setContent(1 params) vs android.widget.HoverPopupWindow#setContent(1 params)
           at [Source: N/A; line: -1, column: -1]

The method android.graphics.Paint#setMyanmarEncoding and the class android.widget.HoverPopupWindow seem to be part of the hidden android sources.

What is happening here and how can I solve this problem?


I’ve found a workaround by excluding the Paint.class and ignoring the setContent methods from the Android-hidden HoverPopupWindow.class. The related method parameters were defined in HoverPopupWindow.smali (GitHub).

This is how the mixins are applied (before using objectMapper.convertValue):

ObjectMapper objectMapper = new ObjectMapper();
objectMapper.addMixIn(android.graphics.Paint.class, IgnoreType.class);
objectMapper.addMixIn(Object.class, IgnoreMethods.class);

The mixin classes are defined like the following:

public class IgnoreType {}

interface IgnoreMethods {
    void setContent(int resId);

    void setContent(View view);

    void setContent(View view, ViewGroup.LayoutParams lp);

    void setContent(CharSequence text);

Unfortunately, I still don’t know why the mapper tries to instantiate Paint and HoverPopupView classes on this specific device.

Leave a Reply

Your email address will not be published. Required fields are marked *