-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Debugging and Error Handling
For information on Glide v4, see the documentation. This wiki covers Glide v3 only.
Exceptions during loads in Glide are not logged by default, but Glide gives you two ways to view and/or respond to these exceptions.
To simply view exceptions when they occur, you can turn on debug logging for Glide's GenericRequest
class that handles responses for all media loads. To do so, in the command line, run:
adb shell setprop log.tag.GenericRequest DEBUG
To include verbose request timing logs you can also pass in VERBOSE
instead of DEBUG
.
To disable logging, run:
adb shell setprop log.tag.GenericRequest ERROR
Debugging workflow
To view how and when Glide's internal engine finds the resources you asked for, you can enable logging:
adb shell setprop log.tag.Engine VERBOSE
adb shell setprop log.tag.EngineJob VERBOSE
adb shell setprop log.tag.DecodeJob VERBOSE
Enabling this will help you find out why a certain resource is not being loaded from memory cache or why is a load downloading the data from the external Url again. This is also useful to learn which arguments need to match when trying to hit the disk caches. Enabling DecodeJob
logging can also help finding out custom transformation/decoder/encoder related issues.
Although enabling debug logging is simple, it's only possible if you have access to the device. To integrate Glide with a pre-existing or more sophisticated error logging system, you can use the RequestListener
class. onException()
will be called when the request fails and will provide the Exception
that caused the failure, or null
if a decoder was unable to decode anything useful from the data it received. You can pass your listener in to each request using the listener()
API.
Be sure to return false
from onException()
to avoid overriding Glide's default error handling behavior (for example notifying the Target
of the error).
Here's an example implementation for quick debugging purposes:
// example usage: .listener(new LoggingListener<String, GlideDrawable>())
public class LoggingListener<T, R> implements RequestListener<T, R> {
@Override public boolean onException(Exception e, Object model, Target target, boolean isFirstResource) {
android.util.Log.d("GLIDE", String.format(Locale.ROOT,
"onException(%s, %s, %s, %s)", e, model, target, isFirstResource), e);
return false;
}
@Override public boolean onResourceReady(Object resource, Object model, Target target, boolean isFromMemoryCache, boolean isFirstResource) {
android.util.Log.d("GLIDE", String.format(Locale.ROOT,
"onResourceReady(%s, %s, %s, %s, %s)", resource, model, target, isFromMemoryCache, isFirstResource));
return false;
}
}
Make sure to remove any usages of this class before releasing your application!
This list was created for 3.6.0 and may not be complete.
cd .../android-sdk/platform-tools
adb shell setprop log.tag.AnimatedGifEncoder VERBOSE
adb shell setprop log.tag.AssetUriFetcher VERBOSE
adb shell setprop log.tag.BitmapEncoder VERBOSE
adb shell setprop log.tag.BufferedIs VERBOSE
adb shell setprop log.tag.ByteArrayPool VERBOSE
adb shell setprop log.tag.CacheLoader VERBOSE
adb shell setprop log.tag.ContentLengthStream VERBOSE
adb shell setprop log.tag.DecodeJob VERBOSE
adb shell setprop log.tag.DiskLruCacheWrapper VERBOSE
adb shell setprop log.tag.Downsampler VERBOSE
adb shell setprop log.tag.Engine VERBOSE
adb shell setprop log.tag.EngineRunnable VERBOSE
adb shell setprop log.tag.GenericRequest VERBOSE
adb shell setprop log.tag.GifDecoder VERBOSE
adb shell setprop log.tag.GifEncoder VERBOSE
adb shell setprop log.tag.GifHeaderParser VERBOSE
adb shell setprop log.tag.GifResourceDecoder VERBOSE
adb shell setprop log.tag.Glide VERBOSE
adb shell setprop log.tag.ImageHeaderParser VERBOSE
adb shell setprop log.tag.ImageVideoDecoder VERBOSE
adb shell setprop log.tag.IVML VERBOSE
adb shell setprop log.tag.LocalUriFetcher VERBOSE
adb shell setprop log.tag.LruBitmapPool VERBOSE
adb shell setprop log.tag.MediaStoreThumbFetcher VERBOSE
adb shell setprop log.tag.MemorySizeCalculator VERBOSE
adb shell setprop log.tag.PreFillRunner VERBOSE
adb shell setprop log.tag.ResourceLoader VERBOSE
adb shell setprop log.tag.RMRetriever VERBOSE
adb shell setprop log.tag.StreamEncoder VERBOSE
adb shell setprop log.tag.TransformationUtils VERBOSE
For information on Glide v4, see the documentation. This wiki covers Glide v3 only.