iBotPeaches/Apktool · error · AndrolibException

Library package not found: id=0x%02x

Error message

Library package not found: id=0x%02x

What it means

ResTable tried to resolve a reference into a shared-library package: it looked up the library by name in the configured library files, loaded them, but no package group with the expected ID appeared in the table. The message names the package ID that stayed missing.

Source

Thrown at brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/ResTable.java:231

        } else {
            name = mDynamicRefTable.get(id);
            if (name == null) {
                return null;
            }
        }

        String[] fileNames = mConfig.getLibraryFiles().get(name);
        if (fileNames == null) {
            return null;
        }

        for (String fileName : fileNames) {
            loadPackagesFromApk(new File(fileName));
        }

        ResPackageGroup pkgGroup = mPackageGroups.get(id);
        if (pkgGroup == null) {
            throw new AndrolibException(String.format("Library package not found: id=0x%02x", id));
        }

        mLibPackageIds.add(id);
        return pkgGroup;
    }

    private ResPackageGroup loadFrameworkById(int id) throws AndrolibException {
        if (mFramePackageIds.contains(id)) {
            return mPackageGroups.get(id);
        }

        loadPackagesFromApk(new Framework(mConfig).getApkFile(id));

        ResPackageGroup pkgGroup = mPackageGroups.get(id);
        if (pkgGroup == null) {
            throw new AndrolibException(String.format("Framework package not found: id=0x%02x", id));
        }

View on GitHub (pinned to 79b63384d7)

Solutions

  1. Supply the correct shared-library APKs via the apktool config (libraryFiles) so the referenced package ID resolves
  2. Update apktool — shared-library/dynamic-reference handling differs between versions and newer releases resolve more layouts
  3. Pull the exact library APKs from the same device/ROM the target app came from (paths like /system/framework/*.apk or /system_ext/framework) and register them
  4. Verify which ID is failing (the message hex) and dump the candidate library APK (`aapt dump resources lib.apk`) to confirm it really owns that package ID

Example fix

// before
Config config = new Config();
// no library files configured -> Library package not found: id=0x0b
ApkDecoder decoder = new ApkDecoder(config);

// after
Config config = new Config();
config.setLibraryFiles(Map.of(
    "com.example.oemlib",
    new String[] { "/system/framework/com.example.oemlib.apk" }));
ApkDecoder decoder = new ApkDecoder(config);
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify each configured library APK actually provides its package id
Config config = new Config();
for (Map.Entry<String, String[]> lib : config.getLibraryFiles().entrySet()) {
    for (String f : lib.getValue()) {
        try (ZipFile zf = new ZipFile(f)) {
            ZipEntry arsc = zf.getEntry("resources.arsc");
            if (arsc == null) throw new IllegalStateException("Library APK lacks resources.arsc: " + f);
        }
    }
}

Try / catch

try {
    ResPackageGroup g = table.getPackageGroup(id); // or full decode
} catch (AndrolibException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Library package not found")) {
        // parse the id from the message, then register the matching library APK in Config and retry
    } else { throw e; }
}

Prevention

When it happens

Trigger: An APK references resources from a shared library (package IDs assigned via dynamic reference tables, e.g. com.google.android.maps or OEM libraries) and the APK's metadata lists library files, but those files do not actually contain a package with the referenced ID.

Common situations: Decoding OEM/Google APKs that depend on shared resource libraries without having those libraries available; a mismatch between the library APK version the app was built against and the one supplied via Config; library paths in the config pointing to stale or wrong files.

Related errors


AI-assisted analysis of iBotPeaches/Apktool@79b63384d7 (2026-08-14). Data as JSON: /api/errors/caeffd3bccf27f29. Report an issue: GitHub.