Reputation: 11
I tried to use Coil, Glide and Fresco in Jetpack Compose to load and show image but got an error due to decoding
Firstly i checked Coil and got next error:
java.lang.IllegalStateException: BitmapFactory returned a null bitmap. Often this means BitmapFactory could not decode the image data read from the input source (e.g. network, disk, or memory) as it's not encoded as a valid image format.
Then Glide:
Load failed for [https://c.dns-shop.ru/thumb/st4/fit/200/200/04d0ba06bcd6368cef034b0ff1f84fea/f7ab30662cb7df554dcd3cf872287b8b4ff3c10cf524175e8f3f1836328eede9.jpg] with dimensions [1080x722]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{->Object->Drawable}, REMOTE
Cause (1 of 4): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{->Drawable->Drawable}
Cause (2 of 4): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{->GifDrawable->Drawable}
Cause (3 of 4): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{->Bitmap->BitmapDrawable}
Cause (4 of 4): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{->BitmapDrawable->Drawable}
And Fresco:
ProgressiveDecoder: unknown image format, {uri: https://c.dns-shop.ru/thumb/st4/fit/200/200/04d0ba06bcd6368cef034b0ff1f84fea/f7ab30662cb7df554dcd3cf872287b8b4ff3c10cf524175e8f3f1836328eede9.jpg, firstEncodedBytes: 15BE1C006400E7B69FCA, length: 7279}
Every library had similar error due to decoding and wrong format.
Information about image and meta data here.
My code:
Column(
modifier = Modifier.fillMaxSize()
) {
AsyncImage(
model = ImageRequest.Builder(this@MainActivity)
.data(link)
.diskCachePolicy(CachePolicy.DISABLED)
.build(),
contentDescription = null,
modifier = Modifier
.weight(1f)
.fillMaxSize()
)
FrescoImage(
imageUrl = link,
contentDescription = null,
modifier = Modifier
.weight(1f)
.fillMaxSize()
)
GlideImage(
model = link,
contentDescription = null,
modifier = Modifier
.weight(1f)
.fillMaxSize()
) {
it.diskCacheStrategy(DiskCacheStrategy.NONE)
}
}
How can i solve the problem? Is is possible?
Upvotes: 1
Views: 1046
Reputation: 1337
I had the same problem in my app and the reason was that there was an OkHttp interceptor modifying the responses. Make sure that your requests aren't meddled with somewhere.
Upvotes: 0