asLody/VirtualApp · error · java.lang.IllegalArgumentException

Invalid marker:

Error message

Invalid marker: 

What it means

removeSplit() records removal by creating a marker file named '<splitName>.removed' in the stage directory. createRemoveSplitMarker validates that marker name with FileUtils.isValidExtFilename and throws IllegalArgumentException('Invalid marker: ' + markerName) if the resulting split name would produce an illegal filename.

Solutions

  1. Pass the bare split name (as it appears in APK split naming, without path or '.apk').
  2. Validate with FileUtils.isValidExtFilename(splitName) before calling removeSplit.
  3. Normalize the input: strip directories and known extensions before composing the marker name.

Example fix

// before
session.removeSplit("/sdcard/splits/split_config.xxhdpi.apk"); // IllegalArgumentException

// after
String split = new File("/sdcard/splits/split_config.xxhdpi.apk").getName();
split = split.substring(0, split.length() - ".apk".length());
if (FileUtils.isValidExtFilename(split + ".removed")) {
    session.removeSplit(split);
}
Defensive patterns

Strategy: validation

Validate before calling

String marker = splitName + ".removed";
if (!FileUtils.isValidExtFilename(marker)) {
    throw new IllegalArgumentException("Invalid split name: " + splitName);
}

Type guard

boolean isValidSplitName(String s) {
    return s != null && !s.isEmpty() && FileUtils.isValidExtFilename(s + ".removed");
}

Try / catch

try {
    session.removeSplit(splitName);
} catch (IllegalArgumentException e) {
    // sanitize: strip path/extension and retry once
}

Prevention

When it happens

Trigger: Calling session.removeSplit(splitName) where splitName contains '/', '\\', or other characters invalid in an ext filename, so 'splitName + REMOVE_SPLIT_MARKER_EXTENSION' fails validation.

Common situations: Passing fully-qualified APK paths or resource URIs instead of bare split names (e.g. 'config.arm64' vs 'base.apk'); names built from untrusted input; typos including slashes in split identifiers.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


AI-assisted analysis of asLody/VirtualApp@666fefcb5d (2026-09-09). Data as JSON: /api/errors/f8d79a9209b54191. Report an issue: GitHub.

Appendix: source

Thrown at VirtualApp/lib/src/main/java/com/lody/virtual/server/pm/installer/PackageInstallerSession.java:366

    }

    @Override
    public void removeSplit(String splitName) throws RemoteException {
        if (TextUtils.isEmpty(params.appPackageName)) {
            throw new IllegalStateException("Must specify package name to remove a split");
        }
        try {
            createRemoveSplitMarker(splitName);
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
    }

    private void createRemoveSplitMarker(String splitName) throws IOException {
        try {
            final String markerName = splitName + REMOVE_SPLIT_MARKER_EXTENSION;
            if (!FileUtils.isValidExtFilename(markerName)) {
                throw new IllegalArgumentException("Invalid marker: " + markerName);
            }
            final File target = new File(resolveStageDir(), markerName);
            target.createNewFile();
            Os.chmod(target.getAbsolutePath(), 0 /*mode*/);
        } catch (ErrnoException e) {
            throw new IOException(e);
        }
    }

    @Override
    public void close() throws RemoteException {
        if (mActiveCount.decrementAndGet() == 0) {
            mCallback.onSessionActiveChanged(this, false);
        }
    }

    @Override
    public void commit(IntentSender statusReceiver) throws RemoteException {

View on GitHub (pinned to 666fefcb5d)