alibaba/ARouter · error · IOException

Missing extracted secondary dex file '<path>'

Error message

Missing extracted secondary dex file '<path>'

What it means

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.

Source

Thrown at arouter-api/src/main/java/com/alibaba/android/arouter/utils/ClassUtils.java:142

        //the prefix of extracted file, ie: test.classes
        String extractedFilePrefix = sourceApk.getName() + EXTRACTED_NAME_EXT;

//        如果VM已经支持了MultiDex,就不要去Secondary Folder加载 Classesx.zip了,那里已经么有了
//        通过是否存在sp中的multidex.version是不准确的,因为从低版本升级上来的用户,是包含这个sp配置的
        if (!isVMMultidexCapable()) {
            //the total dex numbers
            int totalDexNumber = getMultiDexPreferences(context).getInt(KEY_DEX_NUMBER, 1);
            File dexDir = new File(applicationInfo.dataDir, SECONDARY_FOLDER_NAME);

            for (int secondaryNumber = 2; secondaryNumber <= totalDexNumber; secondaryNumber++) {
                //for each dex file, ie: test.classes2.zip, test.classes3.zip...
                String fileName = extractedFilePrefix + secondaryNumber + EXTRACTED_SUFFIX;
                File extractedFile = new File(dexDir, fileName);
                if (extractedFile.isFile()) {
                    sourcePaths.add(extractedFile.getAbsolutePath());
                    //we ignore the verify zip part
                } else {
                    throw new IOException("Missing extracted secondary dex file '" + extractedFile.getPath() + "'");
                }
            }
        }

        if (ARouter.debuggable()) { // Search instant run support only debuggable
            sourcePaths.addAll(tryLoadInstantRunDexFile(applicationInfo));
        }
        return sourcePaths;
    }

    static ApplicationInfo getProcessApplicationInfo(Context context) throws PackageManager.NameNotFoundException {
        // Use the ApplicationInfo already attached to this process. Besides avoiding another
        // PackageManager Binder call when the service is temporarily unavailable, this keeps the
        // APK paths consistent with the code that the current process is actually running.
        ApplicationInfo applicationInfo = context.getApplicationInfo();
        if (applicationInfo == null) {
            throw new PackageManager.NameNotFoundException(context.getPackageName());
        }

View on GitHub (pinned to 84f451d244)

Solutions

  1. Clear the app's data (or uninstall/reinstall) so multidex extraction re-runs cleanly
  2. Confirm ARouter.init is called once from Application.onCreate with the correct Application context
  3. Update ARouter to the latest version — older ClassUtils versions have edge-case bugs with newer Android versions
  4. If it only affects specific devices/ROMs, catch the IOException around init and degrade to non-indexed init

Example fix

// before
ARouter.init(this); // throws IOException 'Missing extracted secondary dex file' on some devices
// after
try {
    ARouter.init(this);
} catch (Throwable t) {
    Log.e("App", "ARouter init failed", t); // app still launches, routing degraded
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    ARouter.init(application);
} catch (Throwable t) {
    Log.e(TAG, "ARouter init failed (missing dex?)", t); // degrade gracefully
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of alibaba/ARouter@84f451d244 (2026-09-06). Data as JSON: /api/errors/b48980798f4f5749. Report an issue: GitHub.