MuntashirAkon/AppManager · error · IOException

The number of input and output files are not the same.

Error message

The number of input and output files are not the same.

What it means

OpenPGPCrypto.doActionForFiles pairs input and output files by index and throws IOException if the array lengths differ, since each input needs exactly one output path for the OpenPGP de/en-cryption loop.

Solutions

  1. Populate both arrays in the same iteration over the file list
  2. Validate equal lengths in the caller before invoking doAction and report a clear error
  3. Derive output names from input names (append .pgp / strip extension) so they stay in sync

Example fix

// before
crypto.doAction(Crypto.OPEN_ENCRYPT, inPaths, Collections.singletonList(outPath).toArray(new Path[0]));
// after
Path[] outPaths = new Path[inPaths.length];
for (int i = 0; i < inPaths.length; i++) outPaths[i] = inPaths[i].addExtension("pgp");
crypto.doAction(Crypto.OPEN_ENCRYPT, inPaths, outPaths);
Defensive patterns

Strategy: validation

Validate before calling

if (in.length != out.length || in.length == 0) {
    throw new IllegalArgumentException("OpenPGP input/output arrays must be same non-zero length");
}

Try / catch

try { crypto.doAction(Crypto.OPEN_ENCRYPT, in, out); } catch (IOException e) {
    if (e.getMessage().contains("not the same")) {
        // fix caller-side path pairing
    }
}

Prevention

When it happens

Trigger: Calling doAction (encrypt/decrypt) with mInputFiles.length != mOutputFiles.length, with non-empty input list.

Common situations: Building input/output arrays independently (e.g. recursive scan inputs but hand-listed outputs); reusing one output path for several inputs; stale bookkeeping after some inputs were filtered out.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/7e615b8b679a36b4. Report an issue: GitHub.

Appendix: source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/crypto/OpenPGPCrypto.java:187

    @WorkerThread
    private void doAction(Intent intent, boolean waitForResult) throws IOException {
        if (mIsFileMode) {
            doActionForFiles(intent, waitForResult);
        } else {
            doActionForStream(intent, waitForResult);
        }
    }

    @WorkerThread
    private void doActionForFiles(Intent intent, boolean waitForResult) throws IOException {
        mErrorFlag = false;
        // `files` is never null here
        if (mInputFiles.length == 0) {
            Log.d(TAG, "No files to de/encrypt");
            return;
        }
        if (mInputFiles.length != mOutputFiles.length) {
            throw new IOException("The number of input and output files are not the same.");
        }
        for (int i = 0; i < mInputFiles.length; i++) {
            Path inputPath = mInputFiles[i];
            Path outputPath = mOutputFiles[i];
            Log.i(TAG, "Input: %s\nOutput: %s", inputPath, outputPath);
            InputStream is = inputPath.openInputStream();
            OutputStream os = outputPath.openOutputStream();
            OpenPgpApi api = new OpenPgpApi(mContext, mService.getService());
            Intent result = api.executeApi(intent, is, os);
            mHandler.post(() -> handleResult(result));
            if (waitForResult) waitForResult();
            if (mErrorFlag) {
                outputPath.delete();
                throw new IOException("Error occurred during en/decryption process");
            }
        }
        // Total success
    }

View on GitHub (pinned to 0152f468fc)