Tencent/matrix · error · AndrolibException

Parse xml error,<e.getMessage()>

Error message

Parse xml error,<e.getMessage()>

What it means

XmlPullResourceRefDecoder.decode() wraps IOExceptions encountered while reading the XML stream in AndrolibException("Parse xml error,..."). This is a read failure of the XML input stream (unavailable, closed, truncated, or IO interruption), distinct from the structural XmlPullParserException path.

Solutions

  1. Check the cause IOException message to identify the unread stream/file.
  2. Re-extract the APK to a clean output directory and ensure sufficient disk space.
  3. Confirm the APK contains the expected resource entries (inspect with apktool or unzip -l).

Example fix

// before
// re-running check on a partially extracted directory
// after
FileUtils.deleteDirectory(unzipDir); // clean re-unzip before re-running
task.call();
Defensive patterns

Strategy: try-catch

Validate before calling

ZipEntry entry = zipFile.getEntry(entryName);
if (entry == null) {
    throw new IllegalStateException("Zip entry missing: " + entryName);
}
try (InputStream in = zipFile.getInputStream(entry)) {
    if (in.read() == -1) throw new IllegalStateException("Empty stream: " + entryName);
}

Try / catch

try {
    decoder.decode(inputStream);
} catch (AndrolibException e) {
    if (e.getMessage().startsWith("Parse xml error")) {
        logger.error("XML stream read failed: " + e.getMessage(), e.getCause()); // check disk space / entry integrity
    } else throw e;
}

Prevention

When it happens

Trigger: The InputStream backing decode() (file stream into an APK entry or res/raw resource) throws IOException: missing zip entry, partially extracted file, or closed/failed stream.

Common situations: Incomplete APK extraction caused by low disk space; analyzing an APK whose entries were removed/packed so streams can't be opened; filesystem errors on the unzip output directory.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08). Data as JSON: /api/errors/634513b83def356c. Report an issue: GitHub.

Appendix: source

Thrown at matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/util/XmlPullResourceRefDecoder.java:71

            while (token != XmlPullParser.END_DOCUMENT) {
                switch (token) {
                    case XmlPullParser.START_TAG:
                        handleElement();
                        break;
                    case XmlPullParser.TEXT:
                        handleContent();
                        break;
                    default:
                        break;
                }
                token = mParser.next();
            }
//            Log.i(TAG, "find resource references: %s", resourceRefSet);
            inputStream.close();
        } catch (XmlPullParserException var7) {
            throw new AndrolibException("Could not decode XML," + var7.getMessage(), var7);
        } catch (IOException e) {
            throw new AndrolibException("Parse xml error," + e.getMessage(), e);
        }
    }

    private void handleElement() {
        String tagName = mParser.getName();
        int pointIndex = tagName.lastIndexOf('.');
        if (pointIndex >= 0) {
            tagName = tagName.substring(pointIndex + 1);
        }
        if (!Util.isNullOrNil(tagName)) {
            for (int i = 0; i < mParser.getAttributeCount(); i++) {
                String value = mParser.getAttributeValue(i);
                //Log.d(TAG, "attribute %s, %s", name, value);
                if (!Util.isNullOrNil(value)) {
                    if (value.startsWith("@")) {
                        int index = value.indexOf('/');
                        if (index > 1) {
                            String type = value.substring(1, index);

View on GitHub (pinned to 3b8293bd65)