MuntashirAkon/AppManager · error · BadParcelableException

IllegalAccessException when unmarshalling: " + name

Error message

IllegalAccessException when unmarshalling: " + name

What it means

When reflectively reading the CREATOR field via Field.get(null), an IllegalAccessException can occur if the field is not accessible; ParcelUtils logs the underlying exception and rethrows it as a BadParcelableException.

Source

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

                                + "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 "
                            + "non-null Parcelable.Creator object called "
                            + "CREATOR on class " + name);
                }
                map.put(name, creator);
            }
        }

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Make the CREATOR field public
  2. Check ProGuard/R8 keep rules so visibility of CREATOR is preserved (-keepclassmembers with public static CREATOR)
  3. Verify the class isn't on the hidden-API blocklist for the target Android version

Example fix

// before
static final Parcelable.Creator<MyData> CREATOR = ...;
// after
public static final Parcelable.Creator<MyData> CREATOR = ...;
// proguard
-keepclassmembers class * implements android.os.Parcelable { public static ** CREATOR; }
Defensive patterns

Strategy: try-catch

Try / catch

try {
    T p = ParcelUtils.readParcelable(parcel, loader);
} catch (BadParcelableException e) {
    if (e.getCause() instanceof IllegalAccessException) {
        Log.e(TAG, "CREATOR not accessible — check visibility/keep rules", e);
    }
}

Prevention

When it happens

Trigger: The named class's CREATOR field exists but is non-public (e.g. package-private or protected), and reflection cannot access it from ParcelUtils' context.

Common situations: Hidden/restricted APIs on newer Android versions (blocklist reflection); CREATOR accidentally given default visibility; obfuscation tools (ProGuard/R8) changing visibility.

Related errors


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