{"record":{"id":"d24edb27207793cb","repo":"MuntashirAkon/AppManager","slug":"parcelable-protocol-requires-a-non-null-parcelable-creator","errorCode":null,"errorMessage":"Parcelable protocol requires a non-null Parcelable.Creator object called CREATOR on class \" + name","messagePattern":"Parcelable protocol requires a non-null Parcelable\\.Creator object called CREATOR on class \" \\+ name","errorType":"exception","errorClass":"BadParcelableException","httpStatus":null,"severity":"error","filePath":"libcore/io/src/main/java/aosp/android/content/pm/ParcelUtils.java","lineNumber":92,"sourceCode":"                        throw new BadParcelableException(\"Parcelable protocol requires a \"\n                                + \"Parcelable.Creator object called \"\n                                + \"CREATOR on class \" + name);\n                    }\n                    creator = (Parcelable.Creator<?>) f.get(null);\n                } catch (IllegalAccessException e) {\n                    Log.e(TAG, \"Illegal access when unmarshalling: \" + name, e);\n                    throw new BadParcelableException(\n                            \"IllegalAccessException when unmarshalling: \" + name);\n                } catch (ClassNotFoundException e) {\n                    Log.e(TAG, \"Class not found when unmarshalling: \" + name, e);\n                    throw new BadParcelableException(\"ClassNotFoundException when unmarshalling: \" + name);\n                } catch (NoSuchFieldException e) {\n                    throw new BadParcelableException(\"Parcelable protocol requires a \"\n                            + \"Parcelable.Creator object called \"\n                            + \"CREATOR on class \" + name);\n                }\n                if (creator == null) {\n                    throw new BadParcelableException(\"Parcelable protocol requires a \"\n                            + \"non-null Parcelable.Creator object called \"\n                            + \"CREATOR on class \" + name);\n                }\n                map.put(name, creator);\n            }\n        }\n\n        return creator;\n    }\n}\n","sourceCodeStart":74,"sourceCodeEnd":103,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/libcore/io/src/main/java/aosp/android/content/pm/ParcelUtils.java#L74-L103","documentation":"After resolving the CREATOR field, ParcelUtils checks the retrieved value is non-null. A CREATOR field that is declared but never assigned (null) violates the Parcelable protocol and raises BadParcelableException.","triggerScenarios":"A Parcelable class declares CREATOR but initializes it to null (or assigns it in a static block/constructor that fails or hasn't run), and the class is read from a parcel.","commonSituations":"Placeholder CREATOR = null left from scaffolding; static initialization order/exception leaving CREATOR null; bytecode transformations stripping the initializer.","solutions":["Assign a real Parcelable.Creator instance to the CREATOR field","Check for static-initializer exceptions that could leave CREATOR null","Remove leftover scaffolding placeholders and complete the Parcelable implementation"],"exampleFix":"// before\npublic static final Parcelable.Creator<MyData> CREATOR = null;\n// after\npublic static final Parcelable.Creator<MyData> CREATOR = new Parcelable.Creator<MyData>() {\n    public MyData createFromParcel(Parcel in) { return new MyData(in); }\n    public MyData[] newArray(int size) { return new MyData[size]; }\n};","handlingStrategy":"validation","validationCode":"try {\n    Object c = Class.forName(name, false, loader).getField(\"CREATOR\").get(null);\n    if (c == null) throw new IllegalStateException(\"CREATOR is null on \" + name);\n} catch (ReflectiveOperationException e) { /* handle */ }","typeGuard":null,"tryCatchPattern":"try {\n    T p = ParcelUtils.readParcelable(parcel, loader);\n} catch (BadParcelableException e) {\n    Log.e(TAG, \"Null CREATOR — check static init of \" + name, e);\n}","preventionTips":["Initialize CREATOR inline; never leave it null","Watch for static-init exceptions in Parcelable classes","Unit-test createFromParcel for every Parcelable"],"tags":["parcel","android","null","serialization"],"backgroundTag":"incompatible-source-type","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}