iBotPeaches/Apktool · error · AndrolibException

Could not create framework directory:

Error message

Could not create framework directory: 

What it means

AndrolibException from Framework.getDirectory() when the framework directory does not exist and File.mkdirs() fails to create it. mkdirs() returns false on permission denial, read-only filesystems, or when an ancestor turns out to be a file (race). Without the directory, framework APKs (1.apk, tagged variants) cannot be written, so framework installation/lookup aborts.

Source

Thrown at brut.apktool/apktool-lib/src/main/java/brut/androlib/res/Framework.java:156

        return table;
    }

    public File getDirectory() throws AndrolibException {
        if (mDirectory == null) {
            String path = mConfig.getFrameworkDirectory();
            File dir = (path != null && !path.isEmpty()) ? new File(path) : DEFAULT_DIRECTORY;

            if (dir.exists() && !dir.isDirectory()) {
                throw new AndrolibException("Framework path is not a directory: " + dir);
            }

            File parent = dir.getParentFile();
            if (parent != null && parent.exists() && !parent.isDirectory()) {
                throw new AndrolibException("Framework path's parent is not a directory: " + parent);
            }

            if (!dir.exists() && !dir.mkdirs()) {
                throw new AndrolibException("Could not create framework directory: " + dir);
            }

            mDirectory = dir;
        }

        return mDirectory;
    }

    public File getApkFile(int id) throws AndrolibException {
        return getApkFile(id, mConfig.getFrameworkTag());
    }

    public File getApkFile(int id, String tag) throws AndrolibException {
        File dir = getDirectory();
        File apkFile = new File(dir, id + getApkSuffix(tag));
        if (apkFile.exists()) {
            return apkFile;
        }

View on GitHub (pinned to 79b63384d7)

Solutions

  1. Use a writable location: `apktool if fw.apk --frame-path ~/.local/share/apktool/framework`.
  2. Fix permissions/ownership of the intended parent directory (chmod/chown or sudo).
  3. If on a read-only mount, remount rw or pick another path.

Example fix

# before
apktool if fw.apk --frame-path /usr/share/apktool/fw   # not writable
# after
mkdir -p ~/.local/share/apktool/fw
apktool if fw.apk --frame-path ~/.local/share/apktool/fw
Defensive patterns

Strategy: validation

Validate before calling

File dir = new File(framePath);
if (!dir.exists()) {
    if (!dir.mkdirs()) throw new IllegalStateException("Cannot create framework dir: " + dir
        + " (check write permission on " + dir.getParentFile() + ")");
}

Prevention

When it happens

Trigger: Setting --frame-path under a directory the user cannot write (e.g. /usr/share/... without root); read-only mounts (container images, Live CDs); SELinux denying mkdir on the chosen location.

Common situations: Running apktool as non-root with system-wide frame paths; Docker containers with read-only volumes; hardened macOS SIP locations; disk quota exhausted.

Related errors


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