bumptech/glide · error · IllegalArgumentException
Must not be null or empty
Error message
Must not be null or empty
What it means
Thrown by Preconditions.checkNotEmpty(String) when the string is null or empty (TextUtils.isEmpty). This is Glide's internal null/empty guard used at the boundary of many APIs (URLs, keys, headers). Preconditions is not part of the public API surface but its exceptions surface to callers who pass bad string arguments to public methods that delegate to it.
Source
Thrown at library/src/main/java/com/bumptech/glide/util/Preconditions.java:41
}
@NonNull
public static <T> T checkNotNull(@Nullable T arg) {
return checkNotNull(arg, "Argument must not be null");
}
@NonNull
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
- Null/empty-check the string before calling Glide: if (!url.isNullOrEmpty()) Glide.with(ctx).load(url)...
- Provide a fallback via .error(drawable) or skip the load entirely when the URL is missing
- Annotate your own data fields @Nullable and handle both states explicitly
- Use Kotlin's url?.let { Glide.with(ctx).load(it) } ?: showPlaceholder()
Example fix
// before
Glide.with(ctx).load(item.imageUrl).into(imageView) // imageUrl may be null/""
// after
if (!item.imageUrl.isNullOrEmpty()) {
Glide.with(ctx).load(item.imageUrl).into(imageView)
} else {
imageView.setImageResource(R.drawable.placeholder)
} Defensive patterns
Strategy: validation
Validate before calling
fun loadUrl(url: String?) {
if (url.isNullOrEmpty()) {
imageView.setImageResource(R.drawable.placeholder)
return
}
Glide.with(ctx).load(url).into(imageView)
} Type guard
fun isValidModel(s: String?): Boolean = !s.isNullOrEmpty()
Prevention
- Null/empty-check all string models before passing them to Glide
- Annotate data-model URL fields @Nullable and handle both branches
- Use Kotlin url?.let { ... } ?: showPlaceholder() to make the null branch explicit
When it happens
Trigger: Passing a null or empty String where Glide requires a non-empty one: a null URL/key, an empty cache key override, an empty signature, an empty model string for asString().load().
Common situations: Loading from a nullable field (e.g. JSON-parsed URL) without a null check; an empty EditText URL submitted by the user; a data model whose image URL field is unset.
Related errors
- Must not be 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/323ef45845505fe3.
Report an issue: GitHub.