microg/GmsCore · error · IllegalArgumentException

List has elements of different types: " + innerTypeHelper.ty

Error message

List has elements of different types: " + innerTypeHelper.type + " and " + typedValue.type

What it means

DataBundleUtil.read builds an AnnotatedArrayList from a serialized DataBundle list and requires all elements to share one type (NULL-typed elements are allowed as trailing gaps). If a second element has a different non-NULL type than the first, it throws IllegalArgumentException("List has elements of different types: X and Y"). This is a deserialization integrity check for the wire format.

Source

Thrown at play-services-wearable/src/main/java/org/microg/gms/wearable/databundle/DataBundleUtil.java:356

        @Override
        AnnotatedArrayList<DataMap> loadList(DataMap dataMap, String key) {
            AnnotatedArrayList<DataMap> list = new AnnotatedArrayList<DataMap>(this);
            list.addAll(dataMap.getDataMapArrayList(key));
            return list;
        }
    };

    public static final int LIST_TYPE_CODE = 10;
    static TypeHelper<AnnotatedArrayList<?>> ARRAYLIST = new TypeHelper<AnnotatedArrayList<?>>(LIST_TYPE_CODE) {
        @Override
        AnnotatedArrayList read(DataBundleValue value, List<Asset> assets) {
            TypeHelper innerTypeHelper = NULL;
            for (DataBundleTypedValue typedValue : value.list) {
                if (innerTypeHelper == NULL) {
                    innerTypeHelper = getTypeHelper(typedValue.type);
                } else if (typedValue.type != innerTypeHelper.type && typedValue.type != NULL.type) {
                    throw new IllegalArgumentException("List has elements of different types: " + innerTypeHelper.type + " and " + typedValue.type);
                }
            }
            return innerTypeHelper.readList(value.list, assets);
        }

        @Override
        DataBundleValue create(AnnotatedArrayList<?> value, List<Asset> assets) {
            return new DataBundleValue.Builder().list(value.createList(assets)).build();
        }

        @Override
        void store(DataMap dataMap, String key, AnnotatedArrayList value) {
            value.store(dataMap, key);
        }

        @Override
        AnnotatedArrayList load(DataMap dataMap, String key) {
            return getListInnerTypeHelper(dataMap.getType(key)).loadList(dataMap, key);

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Ensure both sender and receiver use the same (up-to-date) play-services-wearable / microG version so list encoding is consistent.
  2. Check that the sending code writes homogeneous lists (all elements the same type, or trailing NULLs only).
  3. Log the raw DataBundleValue.list contents on the sending side to find where the type change occurs.
  4. Wrap the read in try-catch if mixed types are expected from older peers, and fall back to reading as a generic list.

Example fix

// before
List<Object> items = DataBundleUtil.readList(dataBundle, "key");

// after
try {
    List<Object> items = DataBundleUtil.readList(dataBundle, "key");
} catch (IllegalArgumentException e) {
    Log.w(TAG, "Mixed-type list from sender; discarding", e);
    items = Collections.emptyList();
}
Defensive patterns

Strategy: try-catch

Validate before calling

boolean homogeneous = list.stream().map(v -> v.type).filter(t -> t != NULL.type).distinct().count() <= 1;

Try / catch

try {
    read(value, assets);
} catch (IllegalArgumentException e) {
    Log.w(TAG, "heterogeneous list", e);
}

Prevention

When it happens

Trigger: Deserializing a DataBundle (e.g. received via Wearable MessageClient/DataClient) whose list contains mixed element types (e.g. a String followed by an Integer); typically produced by a writer using an incompatible DataBundle format or corrupted/partially overwritten data.

Common situations: Sender app on a different version of the library writing lists with a different element type scheme; manually constructed DataBundle values with heterogeneous lists; corrupted sync payload between watch and phone.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06). Data as JSON: /api/errors/518bff092e6cd6b8. Report an issue: GitHub.