{"record":{"id":"e4073b97d693b2a1","repo":"MuntashirAkon/AppManager","slug":"classname-could-not-be-found","errorCode":null,"errorMessage":"{className} could not be found.","messagePattern":"(.+?) could not be found\\.","errorType":"exception","errorClass":"ClassNotFoundException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/dex/DexClasses.java","lineNumber":142,"sourceCode":"            mOptions.inlineResolver = InlineMethodResolver.createInlineMethodResolver(\n                    ((DexBackedOdexFile) dexFile).getOdexVersion());\n        }\n    }\n\n    @NonNull\n    public List<String> getClassNames() {\n        return new ArrayList<>(mClassNameClassDefMap.keySet());\n    }\n\n    @NonNull\n    public List<String> getBaseClassNames() {\n        return new ArrayList<>(mBaseClassNestedClassMap.keySet());\n    }\n\n    @NonNull\n    public ClassDef getClassDef(@NonNull String className) throws ClassNotFoundException {\n        ClassDef classDef = mClassNameClassDefMap.get(className);\n        if (classDef == null) throw new ClassNotFoundException(className + \" could not be found.\");\n        return classDef;\n    }\n\n    @NonNull\n    public String getJavaCode(@NonNull String className) throws ClassNotFoundException {\n        try {\n            String baseClass = DexUtils.getClassNameWithoutInnerClasses(className);\n            List<String> classes = mBaseClassNestedClassMap.get(baseClass);\n            if (classes == null || classes.isEmpty() || !classes.contains(className)) {\n                throw new ClassNotFoundException();\n            }\n            List<ClassDef> classDefs = new ArrayList<>(classes.size());\n            for (String cls : classes) {\n                classDefs.add(getClassDef(cls));\n            }\n            return DexUtils.toJavaCode(classDefs, mOpcodes);\n        } catch (IOException e) {\n            throw new ClassNotFoundException(e.getMessage(), e);","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/dex/DexClasses.java#L124-L160","documentation":"getClassDef(className) looks up a dexlib2 ClassDef from the map built when DexClasses was constructed. If the requested class name isn't present in any of the loaded dex files — wrong class name, class in a dex that wasn't loaded, or the name needs a different format (e.g. L-com/example/Foo; internal form vs dotted) — it throws ClassNotFoundException(className + ' could not be found.').","triggerScenarios":"Calling getClassDef/getJavaCode/getClassContents/buildTree with a class name that is absent from mClassNameClassDefMap: misspelled name, class lives in a dynamic feature/other dex file not passed to the constructor, name passed in dotted ('com.example.Foo') while the map is keyed by smali-style 'Lcom/example/Foo;', or ProGuard/R8 renamed/removed the class.","commonSituations":"Reflecting on an obfuscated release APK where the class was renamed (a.b.c) or stripped; looking up a class from a split APK whose dex wasn't loaded; using the wrong name format after copying from Java source.","solutions":["Convert the class name to smali/internal form (Lcom/example/Foo;) before lookup, or normalize both sides","Check getClassList()/the class-tree for the actual (possibly obfuscated) name and use that","Load all dex files containing the target class (splits, dynamic features) into DexClasses","Verify the class exists in the APK's dex (e.g. via dexdump) and wasn't removed by R8/ProGuard"],"exampleFix":"// before\ndexClasses.getJavaCode(\"com.example.Foo\"); // ClassNotFoundException\n// after\nString smaliName = \"L\" + \"com.example.Foo\".replace('.', '/') + \";\";\nif (dexClasses.getClassList().contains(smaliName)) {\n    dexClasses.getJavaCode(smaliName);\n} else {\n    throw new ClassNotFoundException(smaliName + \" not in loaded dex files\");\n}","handlingStrategy":"try-catch","validationCode":"boolean present = dexClasses.getClassList().contains(toSmaliName(className));\nstatic String toSmaliName(String cn) { return \"L\" + cn.replace('.', '/') + \";\"; }","typeGuard":"boolean hasClass(DexClasses dc, String cn) {\n    return dc.getClassList().contains(\"L\" + cn.replace('.', '/') + \";\");\n}","tryCatchPattern":"try {\n    ClassDef def = dexClasses.getClassDef(smaliName);\n} catch (ClassNotFoundException e) {\n    Log.w(TAG, \"Class not in loaded dex (obfuscated or in another split?)\", e);\n}","preventionTips":["Use smali-style internal names (Lcom/example/Foo;) for lookups","Load all dex files (splits, dynamic features) before lookup","Account for R8/ProGuard obfuscation — resolve names from the mapping or the class list first"],"tags":["dex","class-not-found","android","decompilation"],"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-14T11:17:12.474Z"}