glide
glide copied to clipboard
Glide throws error instead of using specified error image when loading bitmap
Glide Version: 4.12.0
Integration libraries: com.github.bumptech.glide:okhttp3-integration:4.12.0
Device/Android Version: Android 11; any device
Issue details / Repro steps / Use case background: Trying to load a contact image as a bitmap via content URI, with fallback in case contact has no contact image:
Expectation: If Glide is unable to load anything from the contact uri, the bitmap specified in .error(...)
will be used.
Actual: java.util.concurrent.ExecutionException
Glide load line / GlideModule
(if any) / list Adapter code (if any):
Glide.with(context)
.asBitmap()
.load(contactUri)
.error(
Glide.with(context)
.asBitmap()
.load(defaultAvatar)
)
.submit(width, height)
.get()
.let { builder.setLargeIcon(it) }
Stack trace / LogCat:
java.util.concurrent.ExecutionException: com.bumptech.glide.load.engine.GlideException: Failed to load resource
There were 3 root causes:
java.io.FileNotFoundException(InputStream is null for content://com.android.contacts/contacts/3)
java.io.FileNotFoundException(Stream I/O not supported on this URI.; URI: content://com.android.contacts/contacts/3, calling user: android.uid.shared:10069, calling package is one of: [com.android.calllogbackup, com.android.providers.userdictionary, com.android.providers.contacts, com.android.providers.blockednumber])
java.io.FileNotFoundException(Stream I/O not supported on this URI.; URI: content://com.android.contacts/contacts/3, calling user: android.uid.shared:10069, calling package is one of: [com.android.calllogbackup, com.android.providers.userdictionary, com.android.providers.contacts, com.android.providers.blockednumber])
call GlideException#logRootCauses(String) for more detail
at com.bumptech.glide.request.RequestFutureTarget.doGet(RequestFutureTarget.java:217)
at com.bumptech.glide.request.RequestFutureTarget.get(RequestFutureTarget.java:130)
me too, only try catch? how to fix this?
It's actually really irritating having to create the stream and check it manually, or use try-catch
Same here,
In case the url
is null
, glide throws an exception instead of using the drawable specified in .error(...)
In case the url
is an empty string or an invalid url, glide throws an exception instead of using the drawable specified in .fallback(...)
Glide.with(this)
.load(url)
.fallback(R.drawable.fallback)
.error(R.drawable.error)
.submit()
.get().apply {
iv_image.setImageDrawable(this)
}
Glide Version: 4.12.0
This issue has been automatically marked as stale because it has not had activity in the last seven days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions.
Still a problem. I've seen it triggered if a user has provided a URL that resolves to something other than an image.
Is there any solution, I use GlideModule it still can't work
fun ImageView.getUrl(url: String) { Glide.with(this) .load(url) .thumbnail( Glide.with(this) .load(R.drawable.spinnerblack) ).error(Glide.with(this).load(R.drawable.akatsuki)) .into(this) }
it works