bumptech/glide · error · IllegalArgumentException
Must not be empty.
Error message
Must not be empty.
What it means
Thrown by Preconditions.checkNotEmpty(Collection) when a non-null Collection is empty (collection.isEmpty()). Used internally where Glide requires at least one element: empty model lists, empty header maps, empty key sets, etc.
Source
Thrown at library/src/main/java/com/bumptech/glide/util/Preconditions.java:49
public static <T> T checkNotNull(@Nullable T arg, @NonNull String message) {
if (arg == null) {
throw new NullPointerException(message);
}
return arg;
}
@NonNull
public static String checkNotEmpty(@Nullable String string) {
if (TextUtils.isEmpty(string)) {
throw new IllegalArgumentException("Must not be null or empty");
}
return string;
}
@NonNull
public static <T extends Collection<Y>, Y> T checkNotEmpty(@NonNull T collection) {
if (collection.isEmpty()) {
throw new IllegalArgumentException("Must not be empty.");
}
return collection;
}
}
View on GitHub (pinned to eb14a895d8)
Solutions
- Guard with if (!collection.isEmpty()) before calling the API
- Provide a fallback branch (placeholder / skip load) for the empty case
- Use Kotlin's collection.takeIf { it.isNotEmpty() }?.let { ... }
- Validate parsed data upstream and either skip rendering or show an empty-state view
Example fix
// before
Glide.with(ctx).load(urls).into(imageView) // urls may be emptyList()
// after
if (urls.isNotEmpty()) {
Glide.with(ctx).load(urls).into(imageView)
} else {
imageView.setImageResource(R.drawable.placeholder)
} Defensive patterns
Strategy: validation
Validate before calling
if (urls.isNotEmpty()) {
Glide.with(ctx).load(urls).into(imageView)
} else {
imageView.setImageResource(R.drawable.placeholder)
} Type guard
fun <T> Collection<T>.isNonEmpty(): Boolean = !isEmpty()
Prevention
- Check collection.isNotEmpty() before passing to Glide APIs that require entries
- Show an empty-state UI when collections are empty rather than forcing a load
- Validate parsed JSON collections upstream
When it happens
Trigger: Passing an empty List/Set/Map to a Glide API that requires at least one entry; e.g. an empty list of URLs to a multi-model load, an empty headers map, an empty set of decoder keys.
Common situations: UI state where a list of items is filtered down to zero before bind; deserialized JSON collections that came back empty; default-initialized empty collections passed where required.
Related errors
- Must not be null or empty
- sizeMultiplier must be between 0 and 1
- File unsuitable for memory mapping
- Multiplier must be >= 0
- sizeMultiplier must be between 0 and 1
AI-assisted analysis of bumptech/glide@eb14a895d8 (2026-08-14).
Data as JSON: /api/errors/979b94d32d890f17.
Report an issue: GitHub.