bumptech/glide · error · FileNotFoundException
FileDescriptor is null for: {uri}
Error message
FileDescriptor is null for: {uri} What it means
AssetFileDescriptorLocalUriFetcher loads a local content Uri by calling openAssetFileDescriptor through the ContentResolver. If the resolver returns null, no file descriptor could be opened for that Uri, and Glide throws a FileNotFoundException with the Uri in the message. This typically indicates the content at the Uri does not exist or is not accessible.
Source
Thrown at library/src/main/java/com/bumptech/glide/load/data/AssetFileDescriptorLocalUriFetcher.java:31
public AssetFileDescriptorLocalUriFetcher(ContentResolver contentResolver, Uri uri) {
super(contentResolver, uri);
}
/**
* useMediaStoreApisIfAvailable is part of an experiment and the constructor can be removed in a
* future version.
*/
public AssetFileDescriptorLocalUriFetcher(
ContentResolver contentResolver, Uri uri, boolean useMediaStoreApisIfAvailable) {
super(contentResolver, uri, useMediaStoreApisIfAvailable);
}
@Override
protected AssetFileDescriptor loadResource(Uri uri, ContentResolver contentResolver)
throws FileNotFoundException {
AssetFileDescriptor result = openAssetFileDescriptor(uri);
if (result == null) {
throw new FileNotFoundException("FileDescriptor is null for: " + uri);
}
return result;
}
@Override
protected void close(AssetFileDescriptor data) throws IOException {
data.close();
}
@NonNull
@Override
public Class<AssetFileDescriptor> getDataClass() {
return AssetFileDescriptor.class;
}
}
View on GitHub (pinned to eb14a895d8)
Solutions
- Verify the Uri still resolves by querying the ContentResolver before attempting to load
- Handle FileNotFoundException in your RequestListener#error and show a placeholder
- Ensure you have the necessary runtime permissions (READ_CONTACTS, READ_EXTERNAL_STORAGE) before loading
- If the content provider does not support AssetFileDescriptor, register a custom ModelLoader that uses a stream-based fetcher instead
Example fix
// before
Glide.with(context).load(contactUri).into(imageView);
// after — guard with existence check + error handling
Glide.with(context)
.load(contactUri)
.error(R.drawable.ic_person)
.listener(new RequestListener<Drawable>() {
@Override public boolean onLoadFailed(GlideException e, Object model, Target<Drawable> t, boolean isFirst) {
Log.w(TAG, "Asset unavailable for " + model, e);
return false;
}
@Override public boolean onResourceReady(Drawable r, Object m, Target<Drawable> t, DataSource d, boolean i) { return false; }
})
.into(imageView); Defensive patterns
Strategy: try-catch
Validate before calling
// Verify the Uri resolves before loading
private boolean isUriValid(ContentResolver cr, Uri uri) {
try (Cursor c = cr.query(uri, null, null, null, null)) {
return c != null && c.moveToFirst();
}
}
// Only load if valid:
if (isUriValid(getContentResolver(), uri)) {
Glide.with(context).load(uri).into(imageView);
} Try / catch
Glide.with(context)
.load(uri)
.error(R.drawable.placeholder)
.listener(new RequestListener<Drawable>() {
@Override public boolean onLoadFailed(GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
// FileNotFoundException from AssetFileDescriptorLocalUriFetcher surfaces here
Log.w(TAG, "Failed to load: " + model, e);
return false; // let .error() placeholder show
}
@Override public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
return false;
}
})
.into(imageView); Prevention
- Verify content Uris resolve before passing them to Glide
- Ensure runtime permissions (READ_CONTACTS, READ_EXTERNAL_STORAGE) are granted
- Always provide .error() and .fallback() drawables for local Uri loads
- Do not persist content Uris across sessions without re-validating
When it happens
Trigger: Loading a content:// Uri for a file that has been deleted. Loading a media Uri after a permissions change. The content provider backing the Uri does not support openAssetFileDescriptor for that MIME type.
Common situations: Loading contact photos or media store content that was removed between the time the Uri was obtained and the load attempt. Stale Uri references from saved instance state. Content provider that only implements openFileDescriptor but not openAssetFileDescriptor.
Related errors
- FileDescriptor is null for: {uri}
- InputStream is null for {uri}
- Contact cannot be found
- Constructor for {} accepts too many parameters, it should ac
- Unrecognized type: {}
AI-assisted analysis of bumptech/glide@eb14a895d8 (2026-08-14).
Data as JSON: /api/errors/eebfcc1109784632.
Report an issue: GitHub.