{"record":{"id":"518bff092e6cd6b8","repo":"microg/GmsCore","slug":"list-has-elements-of-different-types-innertyp","errorCode":null,"errorMessage":"List has elements of different types: \" + innerTypeHelper.type + \" and \" + typedValue.type","messagePattern":"List has elements of different types: \" \\+ innerTypeHelper\\.type \\+ \" and \" \\+ typedValue\\.type","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"play-services-wearable/src/main/java/org/microg/gms/wearable/databundle/DataBundleUtil.java","lineNumber":356,"sourceCode":"\n        @Override\n        AnnotatedArrayList<DataMap> loadList(DataMap dataMap, String key) {\n            AnnotatedArrayList<DataMap> list = new AnnotatedArrayList<DataMap>(this);\n            list.addAll(dataMap.getDataMapArrayList(key));\n            return list;\n        }\n    };\n\n    public static final int LIST_TYPE_CODE = 10;\n    static TypeHelper<AnnotatedArrayList<?>> ARRAYLIST = new TypeHelper<AnnotatedArrayList<?>>(LIST_TYPE_CODE) {\n        @Override\n        AnnotatedArrayList read(DataBundleValue value, List<Asset> assets) {\n            TypeHelper innerTypeHelper = NULL;\n            for (DataBundleTypedValue typedValue : value.list) {\n                if (innerTypeHelper == NULL) {\n                    innerTypeHelper = getTypeHelper(typedValue.type);\n                } else if (typedValue.type != innerTypeHelper.type && typedValue.type != NULL.type) {\n                    throw new IllegalArgumentException(\"List has elements of different types: \" + innerTypeHelper.type + \" and \" + typedValue.type);\n                }\n            }\n            return innerTypeHelper.readList(value.list, assets);\n        }\n\n        @Override\n        DataBundleValue create(AnnotatedArrayList<?> value, List<Asset> assets) {\n            return new DataBundleValue.Builder().list(value.createList(assets)).build();\n        }\n\n        @Override\n        void store(DataMap dataMap, String key, AnnotatedArrayList value) {\n            value.store(dataMap, key);\n        }\n\n        @Override\n        AnnotatedArrayList load(DataMap dataMap, String key) {\n            return getListInnerTypeHelper(dataMap.getType(key)).loadList(dataMap, key);","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-wearable/src/main/java/org/microg/gms/wearable/databundle/DataBundleUtil.java#L338-L374","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure both sender and receiver use the same (up-to-date) play-services-wearable / microG version so list encoding is consistent.","Check that the sending code writes homogeneous lists (all elements the same type, or trailing NULLs only).","Log the raw DataBundleValue.list contents on the sending side to find where the type change occurs.","Wrap the read in try-catch if mixed types are expected from older peers, and fall back to reading as a generic list."],"exampleFix":"// before\nList<Object> items = DataBundleUtil.readList(dataBundle, \"key\");\n\n// after\ntry {\n    List<Object> items = DataBundleUtil.readList(dataBundle, \"key\");\n} catch (IllegalArgumentException e) {\n    Log.w(TAG, \"Mixed-type list from sender; discarding\", e);\n    items = Collections.emptyList();\n}","handlingStrategy":"try-catch","validationCode":"boolean homogeneous = list.stream().map(v -> v.type).filter(t -> t != NULL.type).distinct().count() <= 1;","typeGuard":null,"tryCatchPattern":"try {\n    read(value, assets);\n} catch (IllegalArgumentException e) {\n    Log.w(TAG, \"heterogeneous list\", e);\n}","preventionTips":["Sync library versions across sender/receiver apps","Enforce homogeneous lists at write time","Validate payloads before deserialization"],"tags":["android","wearable","deserialization","data-bundle"],"backgroundTag":"incompatible-source-type","analyzedSha":"157c9d86ac46c195a86c2f15ab55c84036223f95","analyzedAt":"2026-09-06T17:27:33.892Z","contentChangedAt":"2026-09-06T17:27:33.892Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}