0

I am using Glide in my Android app to crop and cache a bitmap that I then post to my API. I handle the threading with Anko. This is my code:

val bitmap=preview_image_view.drawable as BitmapDrawable //I previously used `preview_image_view.setDrawable` to set this image. It shows properly in the debugger!
doAsync{ //an Anko specific thing
    val file= Glide.with(applicationContext).asFile().load(bitmap).apply(RequestOptions().apply{
        diskCacheStrategy(DiskCacheStrategy.RESOURCE)
        centerCrop()
        override()
    }).submit().get() //Mysterious failure on submit()
    uiThread{ //another Anko specific thing
        Fuel.upload(.....

I get the following error whenever I hit the submit() function

W/Glide: Load failed for android.graphics.drawable.BitmapDrawable@fb798b8 with size [400x400]

class com.bumptech.glide.load.engine.GlideException: Failed to load resource

Glide gives me no causes, stack trace, etc. to help me find why this error is occuring. Any ideas as to what is causing it to fail?

1 Answers1

0

I later discovered the reason for the Glide image load failure. The image I was attempting to cache exceeded the size of the Android application cache, but did not provide an informative error. Later, Glide tried to load the corrupted data (an image that had size 0), but could not.

Downsizing the image before caching it (making sure it was under the Android application cache size limit) solved the issue.