{"record":{"id":"b48980798f4f5749","repo":"alibaba/ARouter","slug":"missing-extracted-secondary-dex-file-path","errorCode":null,"errorMessage":"Missing extracted secondary dex file '<path>'","messagePattern":"Missing extracted secondary dex file '<path>'","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"arouter-api/src/main/java/com/alibaba/android/arouter/utils/ClassUtils.java","lineNumber":142,"sourceCode":"        //the prefix of extracted file, ie: test.classes\n        String extractedFilePrefix = sourceApk.getName() + EXTRACTED_NAME_EXT;\n\n//        如果VM已经支持了MultiDex，就不要去Secondary Folder加载 Classesx.zip了，那里已经么有了\n//        通过是否存在sp中的multidex.version是不准确的，因为从低版本升级上来的用户，是包含这个sp配置的\n        if (!isVMMultidexCapable()) {\n            //the total dex numbers\n            int totalDexNumber = getMultiDexPreferences(context).getInt(KEY_DEX_NUMBER, 1);\n            File dexDir = new File(applicationInfo.dataDir, SECONDARY_FOLDER_NAME);\n\n            for (int secondaryNumber = 2; secondaryNumber <= totalDexNumber; secondaryNumber++) {\n                //for each dex file, ie: test.classes2.zip, test.classes3.zip...\n                String fileName = extractedFilePrefix + secondaryNumber + EXTRACTED_SUFFIX;\n                File extractedFile = new File(dexDir, fileName);\n                if (extractedFile.isFile()) {\n                    sourcePaths.add(extractedFile.getAbsolutePath());\n                    //we ignore the verify zip part\n                } else {\n                    throw new IOException(\"Missing extracted secondary dex file '\" + extractedFile.getPath() + \"'\");\n                }\n            }\n        }\n\n        if (ARouter.debuggable()) { // Search instant run support only debuggable\n            sourcePaths.addAll(tryLoadInstantRunDexFile(applicationInfo));\n        }\n        return sourcePaths;\n    }\n\n    static ApplicationInfo getProcessApplicationInfo(Context context) throws PackageManager.NameNotFoundException {\n        // Use the ApplicationInfo already attached to this process. Besides avoiding another\n        // PackageManager Binder call when the service is temporarily unavailable, this keeps the\n        // APK paths consistent with the code that the current process is actually running.\n        ApplicationInfo applicationInfo = context.getApplicationInfo();\n        if (applicationInfo == null) {\n            throw new PackageManager.NameNotFoundException(context.getPackageName());\n        }","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/alibaba/ARouter/blob/84f451d244e3fb1d0e37801de1b9ee2af2f81d68/arouter-api/src/main/java/com/alibaba/android/arouter/utils/ClassUtils.java#L124-L160","documentation":"ClassUtils.getSourcePaths enumerates the app's dex files so ARouter can scan generated route classes in its class indexer. On ART with legacy multidex, it expects each preloaded secondary dex (classes2.dex.zip etc.) to exist in the optimized dex directory; if the extracted file is missing it throws IOException naming the missing path.","triggerScenarios":"init called with debuggable/legacy multidex where files named extractedFilePrefix+N.zip are absent from the dexDir — typically when the app data was partially cleared, restored from backup, or the code-dir/dex-dir assumptions break on a modified ROM or unusual installer.","commonSituations":"ARouter.init() failing during startup on devices with app clones/dual-instance managers, after a failed OTA/update leaving stale dirs, or on emulators with modified data dirs.","solutions":["Clear the app's data (or uninstall/reinstall) so multidex extraction re-runs cleanly","Confirm ARouter.init is called once from Application.onCreate with the correct Application context","Update ARouter to the latest version — older ClassUtils versions have edge-case bugs with newer Android versions","If it only affects specific devices/ROMs, catch the IOException around init and degrade to non-indexed init"],"exampleFix":"// before\nARouter.init(this); // throws IOException 'Missing extracted secondary dex file' on some devices\n// after\ntry {\n    ARouter.init(this);\n} catch (Throwable t) {\n    Log.e(\"App\", \"ARouter init failed\", t); // app still launches, routing degraded\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    ARouter.init(application);\n} catch (Throwable t) {\n    Log.e(TAG, \"ARouter init failed (missing dex?)\", t); // degrade gracefully\n}","preventionTips":["Call init once from Application.onCreate and swallow unexpected IOExceptions defensively","Keep ARouter updated for multidex edge-case fixes","Treat 'clear app data' as the first troubleshooting step on affected devices","Test cold start on low-end devices and app-clone ROMs"],"tags":["android","arouter","multidex","io","device-compat"],"backgroundTag":"file-not-found","analyzedSha":"84f451d244e3fb1d0e37801de1b9ee2af2f81d68","analyzedAt":"2026-09-06T13:30:41.084Z","contentChangedAt":"2026-09-06T13:30:41.084Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}