MuntashirAkon/AppManager · error · IOException

Failed to create thumbnail

Error message

Failed to create thumbnail

What it means

Wrapped RuntimeException from ThumbnailUtilsCompat.createAudioThumbnail: while extracting embedded album art via MediaMetadataRetriever and decoding it with BitmapFactory, any runtime failure (decoder crash, retriever error) is rethrown as an IOException with this message.

Solutions

  1. Catch the IOException and fall back to a placeholder/default artwork
  2. Pre-scale or stream-decode with BitmapFactory.Options inSampleSize to avoid OOM (custom retriever code)
  3. Validate the file with MediaMetadataRetriever before thumbnailing, skipping corrupt files
  4. Ensure the file is fully readable (not truncated mid-copy) before calling

Example fix

// before
Bitmap bitmap = BitmapFactory.decodeByteArray(raw, 0, raw.length);
return getThumbnail(bitmap, size, true);
// after
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = 2;
Bitmap bitmap = BitmapFactory.decodeByteArray(raw, 0, raw.length, opts);
if (bitmap == null) throw new IOException("No album art found");
return getThumbnail(bitmap, size, true);
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check embedded art presence
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
mmr.setDataSource(path);
byte[] art = mmr.getEmbeddedPicture();
mmr.release();
if (art == null) return null; // no artwork: skip thumbnailing

Try / catch

try {
    return ThumbnailUtilsCompat.createAudioThumbnail(file, size);
} catch (IOException e) {
    if (e.getCause() instanceof OutOfMemoryError) System.gc();
    return placeholderArt;
}

Prevention

When it happens

Trigger: MediaMetadataRetriever.setDataSource succeeds but getEmbeddedPicture() or BitmapFactory.decodeByteArray throws — corrupt audio file, OOM while decoding a huge embedded image, or a native retriever error on a malformed file.

Common situations: Scanning a media library containing corrupt or exotic-format audio files; low-memory devices where a multi-megabyte embedded cover art fails to decode; files with broken ID3/Vorbis picture tags.

Related errors


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/32b45c747d0f2d89. Report an issue: GitHub.

Appendix: source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/compat/ThumbnailUtilsCompat.java:54

     * @param uri     The audio Uri.
     * @param size    The desired thumbnail size.
     * @throws IOException If any trouble was encountered while generating or loading the thumbnail, or if
     *                     {@link CancellationSignal#cancel()} was invoked.
     */
    public static @NonNull Bitmap createAudioThumbnail(@NonNull Context context, @NonNull Uri uri, @NonNull Size size,
                                                       @Nullable CancellationSignal signal) throws IOException {
        // Checkpoint before going deeper
        if (signal != null) signal.throwIfCanceled();

        try (MediaMetadataRetriever retriever = new MediaMetadataRetriever()) {
            retriever.setDataSource(context, uri);
            final byte[] raw = retriever.getEmbeddedPicture();
            if (raw != null) {
                Bitmap bitmap = BitmapFactory.decodeByteArray(raw, 0, raw.length);
                return getThumbnail(bitmap, size, true);
            }
        } catch (RuntimeException e) {
            throw new IOException("Failed to create thumbnail", e);
        }
        throw new IOException("No album art found");
    }

    /**
     * Create a thumbnail for given video file.
     * <p>
     * This method should only be used for files that you have direct access to;
     * if you'd like to work with media hosted outside your app, consider using
     * {@link ContentResolver#loadThumbnail(Uri, Size, CancellationSignal)}
     * which enables remote providers to efficiently cache and invalidate
     * thumbnails.
     *
     * @param context The Context to use when resolving the video Uri.
     * @param uri     The video file.
     * @param size    The desired thumbnail size.
     * @throws IOException If any trouble was encountered while generating or
     *                     loading the thumbnail, or if

View on GitHub (pinned to 0152f468fc)