question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

coil-compose not loading file as image

See original GitHub issue

Describe the bug I have a Java File , which is an image , which was working fine with accompanist version of the library but as soon as I upgraded , Those image files are not being displayed even though they present inside the storage I created these files using context.openFileOutput(id, Context.MODE_PRIVATE) Now I am loading them as File objects since they were saved by the user previously The images are not showing , not even an empty box , Even though rememberImagePainter is being used , The state does not have any error as well

I am also supplying a loader since some images might be an svg

    val loader = remember {
        ImageLoader.Builder(context).componentRegistry {
            add(SvgDecoder(context))
        }.build()
    }

    val painter = rememberImagePainter(data = request, imageLoader = loader)

     Image(
          modifier = modifier,
          painter = painter,
          contentDescription = stringResource(R.string.random_image),
          contentScale = contentScale
      )

Checking for an error like this

 if (painter.state is ImagePainter.State.Error) {
        LaunchedEffect(key1 = painter.state, block = {
            Log.e(
                "TL_AttachmentPhotoImage",
                "Error Loading Image With Request : " + request.toString() + " , isSvg : " + isSvg.toString()
            )
        })
    }

Expected behavior The Images should load and show properly

To Reproduce Use context.openFileOutput to create and save an image load The Image using a file object as a data in the Image Painter

Logs/Screenshots no logs

Version “io.coil-kt:coil-compose:1.3.0”

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
colinrtwhitecommented, Jul 23, 2021

This sounds related to the way rememberImagePainter handles undefined constraint vs. how Accompanist handled it. Try setting Modifier.size(128.dp) (or another size) on the Image composable.

Going to close this out, but feel free to create a new ticket if you’re able to create a sample that reproduces the issue.

0reactions
wakaztahircommented, Jul 22, 2021

Actually there are no logs from image loader , I was using accompanist painter and got success logs but in coil painter there is not a single log

Read more comments on GitHub >

github_iconTop Results From Across the Web

Coil don't load image in emulator with Jetpack Compose
Coil doesn't load images on the emulator because you need to enable clear text traffic, add this line to the application tag in ......
Read more >
Coil-compose not loading image in ConstraintLayout ... - GitHub
Describe the bug Attempt to reopen #813 with a reproducible example Given: The Image needs to have a specified size or else the...
Read more >
Jetpack Compose - Coil
An image loading library for Android backed by Kotlin Coroutines.
Read more >
Jetpack Compose: Image loading using Coil | Geek Culture
Loading images from the Coil library which automatically handling the network request as well as image caching.
Read more >
Coil - Image Loading Library with Jetpack Compose - YouTube
My Online Courses ⭐Discount Coupon: LAUNCH-STEVDZA-SANhttps://stevdza-san.com ‍ Wanna become a member?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found