MuntashirAkon/AppManager · error · IllegalArgumentException

Can't unparcel type " + actual.getName() + " in list of type

Error message

Can't unparcel type " + actual.getName() + " in list of type " + (expected == null ? null : expected.getName())

What it means

BaseParceledListSlice.verifySameType enforces that every element unparceled from a Parcel has exactly the same concrete class as the first element (the declared list element type). A mixed-type list would break the typed List<T> contract, so an IllegalArgumentException naming actual vs expected type is thrown.

Source

Thrown at libcore/io/src/main/java/aosp/android/content/pm/BaseParceledListSlice.java:125

            }
            reply.recycle();
            data.recycle();
        }
    }

    @SuppressWarnings("unchecked")
    private T readCreator(Parcelable.Creator<?> creator, Parcel p, @Nullable ClassLoader loader) {
        if (creator instanceof Parcelable.ClassLoaderCreator<?>) {
            Parcelable.ClassLoaderCreator<?> classLoaderCreator =
                    (Parcelable.ClassLoaderCreator<?>) creator;
            return (T) classLoaderCreator.createFromParcel(p, loader);
        }
        return (T) creator.createFromParcel(p);
    }

    private static void verifySameType(@Nullable final Class<?> expected, @NonNull final Class<?> actual) {
        if (!actual.equals(expected)) {
            throw new IllegalArgumentException("Can't unparcel type "
                    + actual.getName() + " in list of type "
                    + (expected == null ? null : expected.getName()));
        }
    }

    public List<T> getList() {
        return mList;
    }

    /**
     * Set a limit on the maximum number of entries in the array that will be included
     * inline in the initial parcelling of this object.
     */
    public void setInlineCountLimit(int maxCount) {
        mInlineCountLimit = maxCount;
    }

    /**

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Ensure all elements written to the slice are instances of the exact same class (no subclasses with their own CREATOR)
  2. Synchronize the element Parcelable class across both sides of the IPC (same app/library version)
  3. If heterogeneous types are needed, wrap them in a common envelope Parcelable type

Example fix

// before: mixing types in one slice
slice.append(new Item(...)); slice.append(new SpecialItem(...)); // throws on read
// after: single element type, or a common wrapper
slice.append(new Item(...)); slice.append(Item.from(special));
Defensive patterns

Strategy: try-catch

Validate before calling

// Sender side: assert homogeneity before writing
for (Object o : list) {
    if (o.getClass() != list.get(0).getClass())
        throw new IllegalArgumentException("Mixed types in slice: " + o.getClass());
}

Type guard

boolean isHomogeneousList(List<?> list) {
    return list.isEmpty() || list.stream().allMatch(o -> o.getClass() == list.get(0).getClass());
}

Try / catch

try {
    List<T> items = slice.getList();
} catch (IllegalArgumentException e) {
    Log.e(TAG, "Slice type mismatch across IPC — check version skew", e);
    items = Collections.emptyList();
}

Prevention

When it happens

Trigger: Reading a BaseParceledListSlice/ListSlice from a Parcel where a subsequent element's CREATOR returns a different class than the first element's class — i.e. the sender wrote heterogeneous types, or an older/newer process version writes a changed element class mid-list.

Common situations: IPC between app and system/server code at different versions where the slice's element class changed; custom ParcelableCreators that return subclasses; corrupted or hand-crafted parcels.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/7cc05417f3d87b63. Report an issue: GitHub.