{"record":{"id":"61e0481415bc2cfe","repo":"MuntashirAkon/AppManager","slug":"classnotfoundexception-when-unmarshalling-name","errorCode":null,"errorMessage":"ClassNotFoundException when unmarshalling: \" + name","messagePattern":"ClassNotFoundException when unmarshalling: \" \\+ name","errorType":"exception","errorClass":"BadParcelableException","httpStatus":null,"severity":"error","filePath":"libcore/io/src/main/java/aosp/android/content/pm/ParcelUtils.java","lineNumber":85,"sourceCode":"                        throw new BadParcelableException(\"Parcelable protocol requires \"\n                                + \"the CREATOR object to be static on class \" + name);\n                    }\n                    Class<?> creatorType = f.getType();\n                    if (!Parcelable.Creator.class.isAssignableFrom(creatorType)) {\n                        // Fail before calling Field.get(), not after, to avoid initializing\n                        // parcelableClass unnecessarily.\n                        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":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/libcore/io/src/main/java/aosp/android/content/pm/ParcelUtils.java#L67-L103","documentation":"ParcelUtils.readParcelableCreator loads the class named in the Parcel with Class.forName. If the class cannot be found on the given (or default) ClassLoader, the ClassNotFoundException is logged and rethrown as BadParcelableException.","triggerScenarios":"The Parcel contains a class name that is absent at read time: app refactor/renamed class, proguard obfuscation, reading a parcel written by a different app/process whose class isn't on the local classpath, or a wrong loader passed in.","commonSituations":"Restoring persisted bundles after upgrading/refactoring; cross-app IPC with private classes; R8 renaming without keep rules; classloader differences (plugin/dynamic feature classloaders).","solutions":["Pass the correct ClassLoader to readParcelable/readParcelableCreator","Keep the class name stable across versions (add @Keep / proguard keep rule)","Restore the renamed/removed class or migrate the persisted data format","Ensure both IPC sides share the same parcelable class package+name"],"exampleFix":"// before\nParcelable p = ParcelUtils.readParcelable(parcel, null);\n// after\nParcelable p = ParcelUtils.readParcelable(parcel, MyData.class.getClassLoader());","handlingStrategy":"try-catch","validationCode":"boolean classExists(String name, ClassLoader loader) {\n    try { Class.forName(name, false, loader); return true; }\n    catch (ClassNotFoundException e) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n    T p = ParcelUtils.readParcelable(parcel, loader);\n} catch (BadParcelableException e) {\n    if (e.getCause() instanceof ClassNotFoundException) {\n        Log.e(TAG, \"Unknown parcelable class — version skew or missing keep rule\", e);\n    }\n}","preventionTips":["Always pass an explicit ClassLoader (e.g. the app's, not null) when crossing classloader boundaries","Keep parcelable class names stable; use @Keep","Migrate/validate persisted bundles after refactors"],"tags":["parcel","android","classpath","serialization"],"backgroundTag":"class-not-found","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"}