MuntashirAkon/AppManager · error · IllegalStateException
Could not create cache. Is this OS broken?
Error message
Could not create cache. Is this OS broken?
What it means
ImageFileCache's constructor creates the cache directory <cache>/images via mkdirs() and throws IllegalStateException if creation fails. Since File.mkdirs() only fails on real OS-level problems (no permissions, filesystem full/read-only), the message rhetorically asks if the OS is broken. It effectively signals an unrecoverable environment failure at init time.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/self/imagecache/ImageFileCache.java:33
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import io.github.muntashirakon.AppManager.logs.Log;
import io.github.muntashirakon.AppManager.utils.FileUtils;
import io.github.muntashirakon.AppManager.utils.UIUtils;
import io.github.muntashirakon.io.IoUtils;
class ImageFileCache {
private static final long sLastModifiedDate = System.currentTimeMillis() - 604_800_000;
private final File mCacheDir;
public ImageFileCache() {
mCacheDir = new File(FileUtils.getCachePath(), "images");
if (!mCacheDir.exists()) {
if (!mCacheDir.mkdirs()) {
throw new IllegalStateException("Could not create cache. Is this OS broken?");
}
}
}
public void putImage(@NonNull String name, @NonNull InputStream inputStream) throws IOException {
File iconFile = getImageFile(name);
try (OutputStream os = new FileOutputStream(iconFile)) {
IoUtils.copy(inputStream, os);
}
}
public void putImage(@NonNull String name, @NonNull Drawable drawable) throws IOException {
putImage(name, UIUtils.getBitmapFromDrawable(drawable));
}
public void putImage(@NonNull String name, @NonNull Bitmap bitmap) throws IOException {
File iconFile = getImageFile(name);
try (OutputStream os = new FileOutputStream(iconFile)) {View on GitHub (pinned to 0152f468fc)
Solutions
- Check available storage and free space on the device
- Verify Environment/Context cache path is writable before constructing ImageFileCache
- Reboot or clear app data to reset cache directory permissions
- Catch the IllegalStateException and disable image caching as a fallback
Example fix
// before
ImageFileCache cache = new ImageFileCache();
// after
ImageFileCache cache;
try {
cache = new ImageFileCache();
} catch (IllegalStateException e) {
cache = null; // proceed without image caching
} Defensive patterns
Strategy: try-catch
Validate before calling
File cacheDir = new File(FileUtils.getCachePath(), "images");
if (!cacheDir.isDirectory() && !cacheDir.mkdirs()) {
throw new IllegalStateException("Cache dir not creatable: " + cacheDir);
} Try / catch
try {
ImageFileCache cache = new ImageFileCache();
} catch (IllegalStateException e) {
// disable icon caching / show degraded mode
} Prevention
- Verify cache path exists and is writable before first use
- Monitor device free space and degrade gracefully when low
- Catch constructor exceptions at app startup and disable caching instead of crashing
- Treat cache dirs as optional: always guard writes to them
When it happens
Trigger: Constructing ImageFileCache when Context.getCacheDir()/getCachePath() cannot be created or written: read-only filesystem, missing storage permissions, parent path inaccessible, or cache path malformed.
Common situations: Device storage full or mounted read-only (e.g. after USB access on some devices); running on a locked-down/emulated environment; custom ROM with broken cache-dir permissions.
Related errors
- Could not get backup files.
- Could not get backup files
- + path + is inaccessible.
- Couldn't find any writable Obb dir
- Could not get backup files.
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/353add3d9b04eec3.
Report an issue: GitHub.