Konloch/bytecode-viewer · error · RuntimeException

Failed to create temp folder:

Error message

Failed to create temp folder: 

What it means

Apk2Jar.createTempFolder generates a randomized directory name under TEMP_DIRECTORY and calls File.mkdir(); if mkdir returns false the folder was not created (parent missing, permissions, or an existing file/collision) and it throws RuntimeException with the absolute path. This aborts the APK-to-JAR conversion pipeline before any conversion work starts.

Source

Thrown at src/main/java/the/bytecode/club/bytecodeviewer/util/apk2Jar/Apk2Jar.java:41

            return resourceContainerFromApkImpl(inputApk);
        }
    }

    protected abstract ResourceContainer resourceContainerFromApkImpl(File inputApk) throws IOException;

    final protected File createTempJarFile()
    {
        String name = MiscUtils.getRandomizedName() + ".jar";
        return new File(TEMP_DIRECTORY + FS + name);
    }

    final protected File createTempFolder()
    {
        String name = MiscUtils.getRandomizedName();
        File folder = new File(TEMP_DIRECTORY + FS + name);
        if (!folder.mkdir())
        {
            throw new RuntimeException("Failed to create temp folder: " + folder.getAbsolutePath());
        }
        return folder;
    }

    final protected ResourceContainer createResourceContainerFromJar(File output) throws IOException
    {
        return new ResourceContainerImporter(new ResourceContainer(output)).importAsZip().getContainer();
    }

    final protected ResourceContainer createResourceContainerFromFolder(File output) throws IOException
    {
        return new ResourceContainerImporter(new ResourceContainer(output)).importAsFolder().getContainer();
    }

    /**
     * Translates dex classes from an apk to a folder
     *
     * @param input The apk file

View on GitHub (pinned to 31430e0033)

Solutions

  1. Ensure TEMP_DIRECTORY exists (and is writable) before conversion — create it at startup or use mkdirs() instead of mkdir()
  2. Check permissions/ownership of the temp directory for the user running BCV
  3. Point the temp directory at a location you control (e.g. java.io.tmpdir) and verify it is empty/writable
  4. If a name collision occurs, retry with a new randomized name

Example fix

// before
File folder = new File(TEMP_DIRECTORY + FS + name);
if (!folder.mkdir())
    throw new RuntimeException("Failed to create temp folder: " + folder.getAbsolutePath());
// after
File folder = new File(TEMP_DIRECTORY + FS + name);
if (!folder.mkdirs()) // creates missing parents too
    throw new RuntimeException("Failed to create temp folder: " + folder.getAbsolutePath());
Defensive patterns

Strategy: validation

Validate before calling

File tmpRoot = new File(Apk2JarTempRoot);
if (!tmpRoot.isDirectory() && !tmpRoot.mkdirs())
    throw new IOException("Temp root not writable: " + tmpRoot);
if (!tmpRoot.canWrite()) throw new IOException("No write permission: " + tmpRoot);

Try / catch

try {
    File folder = apk2Jar.folder();
} catch (RuntimeException e) {
    if (e.getMessage().startsWith("Failed to create temp folder:")) {
        // fix/verify TEMP_DIRECTORY, then retry with a fresh name
    } else throw e;
}

Prevention

When it happens

Trigger: Calling folder()/createTempFolder() when the parent TEMP_DIRECTORY does not exist (mkdir does not create parents), the process lacks write permission there, or the path already exists.

Common situations: Read-only or unwritable temp directory configuration; TEMP_DIRECTORY pointing at a path whose parents were never created; disk/name collision with an existing entry; sandboxed environments restricting writes to the configured temp root.

Related errors


AI-assisted analysis of Konloch/bytecode-viewer@31430e0033 (2026-09-05). Data as JSON: /api/errors/cf5ced55c2a98ac3. Report an issue: GitHub.