MuntashirAkon/AppManager · error · BadParcelableException

Parcelable protocol requires a Parcelable.Creator object…

Error message

Parcelable protocol requires a Parcelable.Creator object called CREATOR on class " + name

What it means

ParcelUtils.readParcelableCreator requires the class's CREATOR field to be of a type assignable to Parcelable.Creator. If the field exists and is static but has some other type, BadParcelableException is thrown before Field.get() to avoid initializing the class.

Solutions

  1. Change the CREATOR field's declared type to Parcelable.Creator<T>
  2. Rename any unrelated constant that shadows the CREATOR convention
  3. Confirm the class name in the parcel refers to the intended Parcelable class

Example fix

// before
public static final MyCustomFactory CREATOR = new MyCustomFactory();
// after
public static final Parcelable.Creator<MyData> CREATOR = new Parcelable.Creator<MyData>() {...};
Defensive patterns

Strategy: validation

Validate before calling

try {
    Class<?> c = Class.forName(name, false, loader);
    Class<?> t = c.getField("CREATOR").getType();
    if (!Parcelable.Creator.class.isAssignableFrom(t)) throw new IllegalStateException("CREATOR wrong type");
} catch (ReflectiveOperationException e) { /* handle */ }

Try / catch

try {
    T p = ParcelUtils.readParcelable(parcel, loader);
} catch (BadParcelableException e) {
    Log.e(TAG, "CREATOR type invalid on class", e);
}

Prevention

When it happens

Trigger: Reading a Parcelable whose CREATOR field is declared as a non-Creator type (e.g. a custom factory interface, Parcelable.Creator's raw generic in an incompatible hierarchy, or a field named CREATOR of an unrelated type).

Common situations: Refactoring where CREATOR's type was changed; classes with a constant named CREATOR that isn't a Creator; copying parcel-read helpers across unrelated classes.

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 MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/4f7fcf261855e70b. Report an issue: GitHub.

Appendix: source

Thrown at libcore/io/src/main/java/aosp/android/content/pm/ParcelUtils.java:74

                    ClassLoader parcelableClassLoader = (loader == null ? from.getClass().getClassLoader() : loader);
                    // Avoid initializing the Parcelable class until we know it implements
                    // Parcelable and has the necessary CREATOR field.
                    Class<?> parcelableClass = Class.forName(name, false /* initialize */,
                            parcelableClassLoader);
                    if (!Parcelable.class.isAssignableFrom(parcelableClass)) {
                        throw new BadParcelableException("Parcelable protocol requires that the "
                                + "class implements Parcelable");
                    }
                    Field f = parcelableClass.getField("CREATOR");
                    if ((f.getModifiers() & Modifier.STATIC) == 0) {
                        throw new BadParcelableException("Parcelable protocol requires "
                                + "the CREATOR object to be static on class " + name);
                    }
                    Class<?> creatorType = f.getType();
                    if (!Parcelable.Creator.class.isAssignableFrom(creatorType)) {
                        // Fail before calling Field.get(), not after, to avoid initializing
                        // parcelableClass unnecessarily.
                        throw new BadParcelableException("Parcelable protocol requires a "
                                + "Parcelable.Creator object called "
                                + "CREATOR on class " + name);
                    }
                    creator = (Parcelable.Creator<?>) f.get(null);
                } catch (IllegalAccessException e) {
                    Log.e(TAG, "Illegal access when unmarshalling: " + name, e);
                    throw new BadParcelableException(
                            "IllegalAccessException when unmarshalling: " + name);
                } catch (ClassNotFoundException e) {
                    Log.e(TAG, "Class not found when unmarshalling: " + name, e);
                    throw new BadParcelableException("ClassNotFoundException when unmarshalling: " + name);
                } catch (NoSuchFieldException e) {
                    throw new BadParcelableException("Parcelable protocol requires a "
                            + "Parcelable.Creator object called "
                            + "CREATOR on class " + name);
                }
                if (creator == null) {
                    throw new BadParcelableException("Parcelable protocol requires a "

View on GitHub (pinned to 0152f468fc)