{"record":{"id":"905a9e50efcd9956","repo":"iBotPeaches/Apktool","slug":"could-not-find-file-dexname","errorCode":null,"errorMessage":"Could not find file: {dexName}","messagePattern":"Could not find file: (.+?)","errorType":"exception","errorClass":"AndrolibException","httpStatus":null,"severity":"error","filePath":"brut.apktool/apktool-lib/src/main/java/brut/androlib/smali/SmaliDecoder.java","lineNumber":68,"sourceCode":"        mDebugMode = debugMode;\n        mDexFiles = ConcurrentHashMap.newKeySet();\n        mInferredApiLevel = new AtomicInteger();\n    }\n\n    public Set<String> getDexFiles() {\n        return mDexFiles;\n    }\n\n    public int getInferredApiLevel() {\n        return mInferredApiLevel.get();\n    }\n\n    public void decode(String dexName, File outDir) throws AndrolibException {\n        try {\n            // Fetch the requested dex file from the dex container.\n            ZipDexContainer.DexEntry<DexBackedDexFile> dexEntry = mDexContainer.getEntry(dexName);\n            if (dexEntry == null) {\n                throw new AndrolibException(\"Could not find file: \" + dexName);\n            }\n\n            // Add the requested dex file.\n            Map<Integer, DexBackedDexFile> dexFiles = new TreeMap<>();\n            dexFiles.put(1, dexEntry.getDexFile());\n\n            // Add additional dex files if it's a multi-dex container.\n            for (String dexEntryName : mDexContainer.getDexEntryNames()) {\n                if (dexEntryName.equals(dexName)) {\n                    continue;\n                }\n\n                String prefix = dexName + \"/\";\n                if (!dexEntryName.startsWith(prefix)) {\n                    continue;\n                }\n\n                int dexNum;","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/iBotPeaches/Apktool/blob/79b63384d7d7e22917e6ea8b453272da7012515b/brut.apktool/apktool-lib/src/main/java/brut/androlib/smali/SmaliDecoder.java#L50-L86","documentation":"SmaliDecoder.decode(dexName, outDir) asked the ZipDexContainer for a specific dex entry and getEntry returned null, so no such dex file exists in the APK under that exact name. The message names the requested dex name.","triggerScenarios":"Calling decode with a name that does not exactly match an entry in the container, e.g. \"Classes.dex\" vs \"classes.dex\", \"classes2.dex\" vs \"classes2.dex\" with a path prefix, or a name obtained from a different APK than the one opened.","commonSituations":"Hard-coded dex names in scripts after an app changed its multidex layout; case-sensitivity differences between platforms; iterating dex names from one split while decoding another split's file.","solutions":["List the real entry names and use one of them: `unzip -l app.apk | grep dex` or ZipDexContainer.getDexEntryNames()","Check for case/path mismatches (Classes.dex vs classes.dex, leading directories)","If decoding programmatically, derive dex names from the same container instance you decode from","Confirm you opened the intended APK (base vs split), since dex names come from the opened file only"],"exampleFix":"// before\ndecoder.decode(\"Classes.dex\", outDir); // wrong case -> Could not find file\n\n// after\nfor (String name : new ZipFile(apk).stream()\n        .map(ZipEntry::getName)\n        .filter(n -> n.endsWith(\".dex\"))\n        .toList()) {\n    decoder.decode(name, outDir);\n}","handlingStrategy":"validation","validationCode":"// Enumerate real dex names from the container itself before decoding\nCollection<String> names;\ntry {\n    java.lang.reflect.Method unused = null; // placeholder\n    names = new ZipFile(apk).stream().map(ZipEntry::getName)\n        .filter(n -> n.endsWith(\".dex\")).toList();\n} catch (IOException e) { throw new UncheckedIOException(e); }\nif (!names.contains(dexName)) {\n    throw new IllegalArgumentException(\"No such dex entry '\" + dexName + \"' in \" + apk + \"; have: \" + names);\n}","typeGuard":null,"tryCatchPattern":"try {\n    decoder.decode(dexName, outDir);\n} catch (AndrolibException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Could not find file\")) {\n        // list container entries and correct the name; never blind-retry\n    } else { throw e; }\n}","preventionTips":["Always derive dex names from the same container you decode from","Treat dex names as case-sensitive on all platforms","Prefer iterating all entries over hardcoding names like classes2.dex"],"tags":["apktool","dex","multidex","smali"],"backgroundTag":null,"analyzedSha":"79b63384d7d7e22917e6ea8b453272da7012515b","analyzedAt":"2026-08-14T10:43:28.812Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}