Like many others I have tried to retry an image load in the onLoadFailed method of the RequestListener and ended up meeting the following error
java.lang.IllegalStateException: You can't start or clear loads in RequestListener or Target callbacks. If you're trying to start a fallback request when a load fails, use RequestBuilder#error(RequestBuilder). Otherwise consider posting your into() or clear() calls to the main thread using a Handler instead.
I have been trying for quite some time to implement the suggestion provided in the error message

But for some reason it is impossible to instantiate a new RequestBuilder in order for me to use its .error method since it appears both of its constructors are protected.


The documentation lacking any examples whatsoever does not help either.
Is this on purpose or is it being done incorrectly?
Glide.with(context).load() returns a RequestBuilder.
You're expected to do something like:
Glide.with(context)
.load(url)
.error(
Glide.with(context)
.load(fallbackUrl))
.into(imageView);
Would never have got there, thanks for the explanation.
Now that you understand better, would you be up for sending a pull request that clarifies the warning, or adding some documentation to help the next person?
Were you expecting to see an example in the error message itself? Or in the javadoc for RequestBuilder#error? Or in the docs page?
My requirement is that if the image loading fails, it should be loaded all the time in 10 seconds. How to solve this problem?
Most helpful comment
Glide.with(context).load() returns a RequestBuilder.
You're expected to do something like: